Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Is ServerVersion required in connection string?

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-09-19 : 07:46:32
Dev06 writes "I am using the following connection string:
string szConnectString = "Data Source=MyServername;Initial Catalog=MyDataBase; Integrated Security=True";

Even before the connection is opened I can see a exception in my watch window:
<<
Name :ServerVersion
Value:'conn.ServerVersion' threw an exception of type 'System.InvalidOperationException' string {System.InvalidOperationException}
Name:base
Value:{"Invalid operation. The connection is closed."} System.SystemException {System.InvalidOperationException}.
>>

I am able to step into the code and when connection is opened, there is no exception and server version reads the actual version number.Once connection is closed the exception is back.

I am making this connection via an interop call from unamanged to managed, and due to this I get a random StackOverflow in the unmanaged code shortly after the connection is closed and code exits the managed interop call. I am a beginner . Please let me know where I am going wrong. Thanks."

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-09-19 : 07:55:51
You need the Provider in the connection string too.
Also see www.connectionstrings.com



Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -