Re: Connection to SQL Server works in VB.NET, not ASP.NET

From: Kevin Yu [MSFT] (v-kevy_at_online.microsoft.com)
Date: 02/27/04


Date: Fri, 27 Feb 2004 05:28:26 GMT

Hi Roy,

Thank you for posting in the community!

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you received an InvalidCastException
when trying to open an connection to the SQL server. If there is any
misunderstanding, please feel free to reply to the post.

This seems to be a very strange problem. According to the following MSDN
document, SqlConnection.Open method will never throw an
InvalidCastException.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemdatasqlclientsqlconnectionclassopentopic.asp

Please try to check if the connection has been opened before. Please also
try to use the following connection string to connect to a default database
(Northwind) on a SQL server.

Password=PW;Persist Security Info=True;User ID=User;Initial
Catalog=Northwind;Data Source=ServerName

If this works, it means that the there might be something wrong with the
database. If it doesn't work, please use please use the SQL Profiler to
trace the actions performing on the SQL server. We might find which SQL
statement goes wrong from the trace log.

If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."



Relevant Pages