|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Newbie Connection problemI have spent 3 plus hours looking at documentation and references. I
have copied code and changed variables... but still nothing. Here is my connection string and scalar. Dim sqlConn As New SqlConnection("Data Source=*Server;Initial Catalog=*DBName;Integrated Security=SSPI;") Dim sqlComm As New SqlCommand(strSQL, sqlConn) sqlConn.Open() Dim strUserID As Integer = sqlComm.ExecuteScalar() sqlConn.Close() MsgBox(strUserID) The SQL statement is correct and runs perfectly in the query analyzer. It returns a 1 in SQL Server which is the correct result. However it returns a 0 whenever I try to access this data in my .NET windows app. Am I forgetting anything? -Lost on what to do next Johnson wrote:
Show quote > I have spent 3 plus hours looking at documentation and references. I What's the command?> have copied code and changed variables... but still nothing. Here is > my connection string and scalar. > > Dim sqlConn As New SqlConnection("Data Source=*Server;Initial > Catalog=*DBName;Integrated Security=SSPI;") > Dim sqlComm As New SqlCommand(strSQL, sqlConn) > sqlConn.Open() > Dim strUserID As Integer = sqlComm.ExecuteScalar() > sqlConn.Close() > MsgBox(strUserID) > > The SQL statement is correct and runs perfectly in the query analyzer. > It returns a 1 in SQL Server which is the correct result. However it > returns a 0 whenever I try to access this data in my .NET windows app. > Am I forgetting anything? Also, turn Option Strict On (this should be your default mode of operation), and supply the necessary conversion functions. You may discover something. (I know you're not running with Option Strict On, because SqlCommand.ExecuteScalar returns an Object, which needs an explicit conversion to get put into an Integer) -- Larry Lard larryl***@googlemail.com The address is real, but unread - please reply to the group For VB and C# questions - tell us which version Found out that my SQL server is not being recognized as a connection
when the provider is Microsoft SQL Server. It is only being recognized when I use the Microsoft ODBC Driver as the provider? I turned on Option Strict and changed the integer to an object. I also changed the connection and command to ODBC... it still isn't working though. I think I might have to figure out how to get my SQL server recognized as a SQL provider. |
|||||||||||||||||||||||