2

Im trying to add a connection to a database in SQL Server 2008 using Visual Studio 2008. When testing the connection, it says that it is successful. However, once I said okay, it complains and say: "Cannot add data connection. Object reference not set to an instance of an object."

How do I go about adding a data connection to a SQL Server 2008 using Visual Studio 2008?

1
  • are you using visual studio server explorer or doing it from code? please add some details. Commented Dec 14, 2008 at 18:11

2 Answers 2

1

Via code would be something like:

var conn = new SqlConnection([connectionString]);
conn.Open();
Sign up to request clarification or add additional context in comments.

Comments

0

"Object reference not set to an instance of an object" is usually an indicator of not using the Keyword "New".

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.