Click here to Skip to main content
16,017,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I am using vb.net 2003 and Sql 2000 server when I am trying to connect to sql server it generates error.
it says "An unhandled exception of type 'System.NullReferenceException' occurred in System.data.dll"

Here is the code. Please help me.
VB
Private Sub ConnectToSQL()
       Dim con As New SqlConnection
       Dim cmd As New SqlCommand
       con.ConnectionString = "Data Source=(local);Initial Catalog=AACA_Library_db;Persist Security Info=True;User ID=lib;Password=lib"
       con.Open()
   End Sub


Thank you in advance
Posted
Updated 27-May-11 22:49pm
v2
Comments
Sandeep Mewara 28-May-11 4:50am    
Are you sure, above code snippet has the line that throws the error? I doubt it.

Share the complete stacktrace. There must be a line number too - which line it says?

1 solution

Have a check of your connection string. here is a good resource to check the string construction Connection Strings[^]

I would also verify your datasource, catalog, username and password
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900