Posts

Showing posts from September, 2005

Is there a benign virus I can use to test the AV scanner?

Q: Is there a benign virus I can use to test the AV scanner? A: Eicar.org offers a benignvirus used for testing purposes. Although they don't offer support for any specific Anti-virus scanning tool, they can provide a simple virus that would help test your AV application. For more information and to download the virus, visit http://www.eicar.org/anti_virus_test_file.htm . Thanks to Andrew H. for providing an answer to this question.

How to search multiple columns, in 1 or more tables, for a single string?

Q: How can I search all varchar columns in a given table for a specific string, without building the where clause for every field? A: select * from table1 where val1 + val2 like '%xyz%' /* where val1 and val2 are varchar columns */ Also, if you have full text indexes defined on the columns of a table you can use the contains clause to examine each column that is indexed. If all of the varchar columns in mytable are are included in the fulltext index, then following will return any row that has the string abc : select * from mytable where contains(*, '"*abc*" ) Thanks to Pete F. for helping with this question.

IE Tab browsing

For those who enjoy using FireFox because of its ability to browse within tabs, IE is now offering a similar solution. With the help of the MSN toolbar, IE6 is now capable of tab browsing. To download the MSN toolbar, go to http://toolbar.msn.com/ . This is toolbar is a production release, and is free of charge. In addition, several other tools are available on the same page (i.e. Windows Desktop Search, Internet Search tools, etc).

IE Developer Toolbar

In keeping up with FireFox and it's development toolbar, Microsoft released a similar developer toolbar for Internet Explorer. For more information and to download the toolbar, go to http://www.microsoft.com/downloads/details.aspx?FamilyID=e59c3964-672d-4511-bb3e-2d5e1db91038&displaylang=en Please note that this IE toolbar is still a Beta!

Why is "Save" grayed out on MS-Word 2003?

Q: I'm able to open a document in MS-Word 2003, but not able to make changes or save it. Why is "Save" grayed out on MS-Word 2003? A: After some digging, it appeared that a virus had infected the user's system and de-activated Office 2003. After retrieving the registration number and re-activating MS-Office, everything should work fine as expected.

Invalid path for child request

Q: I call another web page from the application and pass it an argument (see sample below), but I receive the error "Invalid path for child request". Dim strPath As String = "Error.aspx?Msg=" & strMsg Server.Transfer(strPath, True) A: Since the argument passed is not URL encoded, it causes the path of the web page being called to be incorrect. To correct the problem simply URL encode the argument being passed to the new page. Dim strPath As String = "Error.aspx?Msg=" & Server.UrlEncode(strMsg) Server.Transfer(strPath, True)

How do you throw an exception?

Q: How do you throw an exception? A: The Throw() method is used to induce an error into the error handling routine. To generate an error, simply declare an object of type "Exception" with the desired message. Then call the Throw() method to send this error message to the error handling routine ("Catch" block). Once Throw() is called, all intermediate code will be skipped and execution will transfer to the "Catch" block, where Ex.Message="Something wrong happened!" See the code example listed below: Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click Try 'Some code logic here... Dim ex As New Exception("Something wrong happened!") Throw ex 'Some code logic here... Catch ex As Exception 'Catch a generic exception. Dim strMsg As String strMsg = "Error: " & Ex.Message & ControlChars.CrLf strMsg &= "Stack Trace: " & Ex.StackTrace & Con

How do you force a user to always login to web app?

Q: How do you force a user to always login? A: In the Login.aspx page, the following code would be placed in the btnLogin_Click(): If wsAuth.Auth(strUID, strPWD) = True Then 'Successful Login FormsAuthentication.SetAuthCookie(txtUserID.Text, False) Response.Redirect("MainMenu.aspx") Else 'Failure ErrorLabel.Text = "Authentication did not succeed. Check user name and password." End If In each subsequent web page, check for authentication before loading the page. The following code would be placed in the Page_load event handler: If Not IsPostBack Then If Not (Request.IsAuthenticated) Then Session.Abandon() Response.Redirect("Login.aspx") End If End If Forcing a Login and redirecting to the user's requested URL. Q: If a user opens a browser and enters a URL to a specific page within a web application without loggin in first, how do you force him to login then redirect him to the page requested? A: If you use

.Net Events

Listed below are several .Net events to note on your calendar: 1. SharePoint SIG: September 12, 2005 @ 6:30 PM. For more info see http://gcpcug.org/sigdetail.php?pick_sig=44 2. C#/VB.NET SIG: September 27, 2005 @ 6:30 PM. For more info see http://www.clevelanddotnet.info 3. MSDN Event: October 04, 2005 @ 1:00 PM, Regal Severance Town Center. For more info, see http://www.msdnevents.com 4. SQL Server 2005, Visual Studio 2005 & BizTalk Server 2006 Launch, Tuesday, November 08, 2005 @ 9:00 AM in Detroit, MI. For more info, see http://msdn.microsoft.com/launch2005

SQL Server & .Net Encryption

Q: I would like to encrypt credit card numbers and ssn numbers in the SQL database. The data will be submitted to the database from a .NET application and will be retrieved from a .NET application. Is there anything within .NET that can encrypt and decrypt the fields? A: There is a System.Security.Cryptography class within .Net that supports various forms of encryption. Also, SQL Server 2000 has a built-in Encrypt() function that can be used. In addition, you should consider encrypting the data crossing the wire from the browser to the server, that's where many security attacks occur.

What is System.DBNull.Value used for?

Q: What is System.DBNull.Value used for? A: System.DBNull.Value is the value of NULL retrieved from a DB. Before assigning a database field to a variable, you should always check to see if the value returned from the DB is NOT null. Otherwise, an exception could be thrown. Example: If Not drPkgRec("MeetDate") Is System.DBNull.Value Then Dim strMeetingPlace = drPkgRec("MeetPlace") End If Note: The Keyword "Is" is used, not "=".

Database Mirroring in SQL Server 2005

I came across an article on TechNet about Database Mirroring. This is an in-depth article that should cover all the details (i.e. what is it, how to use it, etc). http://www.microsoft.com/technet/prodtechnol/sql/2005/dbmirror.mspx

The identifier that starts with "SELECT * FROM ...." is too long. Maximum length is 128.

This morning as I was working on a project, I tested a SQL statement in Query Analyzer, but got the following error: Server: Msg 103, Level 15, State 7, Line 1The identifier that starts with "SELECT * FROM ...." is too long. Maximum length is 128. After searching on the internet, I found a solution at http://support.microsoft.com/default.aspx?scid=kb;EN-US;294839 . Microsoft recommends installing SP1 to resolve this and it worked.

Microsoft Office SharePoint Portal Server 2003 Discovery Kit

The SharePoint Portal Server 2003 Discovery Kit includes a series of discovery labs that go beyond learning about a particular component of SharePoint Portal Server 2003 to understanding how to build a divisional portal site solution, how to deploy Web applications that integrate tightly with the portal site environment, how to use SQL Server 2000 Reporting Services to track and analyze portal site usage, and lastly, how to customize the portal site user interface. There are 6 labs in the SharePoint Portal Server 2003 Discovery Kit. The lab manuals includes a description of the business scenario that is addressed by the lab, the teaching objectives of the lab, step-by-step instructions, dependencies for each lab and the expected amount of time needed for the lab assuming a basic familiarity with Windows SharePoint Services and limited SharePoint Portal Server 2003 experience. http://www.microsoft.com/downloads/details.aspx?familyid=03607516-cbec-4724-b4a4-aa7f09304ba5&displaylang=e