Connecting in a database

  • Thread starter Thread starter Sukist
  • Start date Start date
S

Sukist

Hi all !
I´m with a problem to make a connection in my application.
I´m in VB.net, and using a sql2000 database. When I´m try
to connect to database, I can open the connection, but
can´t execute a stored procedure. My code is:
<code>
Dim objConn as New SqlConnection("Password=123;User
Id=sukist;Initial Catalog=DBMedium;Data
Source=DBSMEDIUMDEV;")
Dim objCmd as sqlCommand
Dim myDataReader as sqldatareader

objCmd = New sqlCommand("SP_GET_LIST")
objCmd.commandtype = commandtype.storedprocedure

myDataReader = objCmd.Execute
(CommandBehavior.CloseConnection)

</code>

The error message is: Login failed for user 'sukist'. But
the error occurs in the line which execute the command.
And if a I try to connect in Query Analyzer, using the
same information of my connectionString, the connection
opens sucefully. Anybody can help me with this?

TIA, Sukist!
 
Hi Sukist,
Use the ExecuteReader method of the command object rather
than the Execute method.
I hope this works. My email has 2 "k"s in it. Have a
great day!! Carol
 
Make sure you ExecuteReader() and then make sure you do something like
while(dr.Read()){
//DoSomething.

}
Hi all !
I´m with a problem to make a connection in my application.
I´m in VB.net, and using a sql2000 database. When I´m try
to connect to database, I can open the connection, but
can´t execute a stored procedure. My code is:
<code>
Dim objConn as New SqlConnection("Password=123;User
Id=sukist;Initial Catalog=DBMedium;Data
Source=DBSMEDIUMDEV;")
Dim objCmd as sqlCommand
Dim myDataReader as sqldatareader

objCmd = New sqlCommand("SP_GET_LIST")
objCmd.commandtype = commandtype.storedprocedure

myDataReader = objCmd.Execute
(CommandBehavior.CloseConnection)

</code>

The error message is: Login failed for user 'sukist'. But
the error occurs in the line which execute the command.
And if a I try to connect in Query Analyzer, using the
same information of my connectionString, the connection
opens sucefully. Anybody can help me with this?

TIA, Sukist!
 
Back
Top