SQL Connexion problem...

T

+The_Taco+

Im trying to insert only one row in my database with the SQLClient class.
But I get this error: "Object reference not set to an instance of an
object". Can anyone tell me why I get this error? Here's my code:

Dim cnn As New SqlClient.SqlConnection

Dim cmd As SqlClient.SqlCommand



Dim strNomServeur As String

Dim strNomDatabase As String

Dim strUserID As String

Dim strUserPWD As String

Dim strRequete As String



strNomServeur = "STAT-1-038"

strNomDatabase = "StockageErreur"

strUserID = "ferodo"

strUserPWD = "taco2000"

strRequete = "INSERT INTO StockageErreur(NomEntrant, NomApplication,
DescriptionErreur, DateEntree, DateRappel, Critique, DateRegle)" & _

"VALUES ('test', 'test', 'test encore', '02/02/02', '02/02/02', 'est',
'02/02/02')"



cnn.ConnectionString = "Data Source=" & strNomServeur & "; Initial Catalog="
& strNomDatabase & "; User ID=" & strUserID & "; Password=" & strUserPWD &
"; "

cnn.Open()

cmd.Connection = cnn '<------- I get the error right here

cmd.CommandText = strRequete

cmd.ExecuteNonQuery()

cmd.Connection.Close()



thx for the help guys!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top