SQL

P

Paul Mars

I think it is my SQL code that is causing the failure here. I receive "An
unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in
system.data.dll" on the second to last line below. What's wrong?

conUserInfo.Open()

Dim cmdAdd As OleDb.OleDbCommand = New OleDb.OleDbCommand


cmdAdd.CommandText = "INSERT UserGame VALUES " & strUserID & ", " &
strPassword & ", " & strAge & ", " & strGender & ", " & blnSound & ", " &
blnSoundAsLast & ", " & decGameSize & ", " & blnSizeAsLast & ", " &
strImagePlacement & ", " & blnImagePlacementAsLast & ""

also tried

cmdAdd.CommandText = "INSERT UserGame VALUES '" & strUserID & "', '" &
strPassword & "', '" & strAge & "', '" & strGender & "', " & blnSound & ", "
& blnSoundAsLast & ", " & decGameSize & ", " & blnSizeAsLast & ", '" &
strImagePlacement & "', " & blnImagePlacementAsLast & ""

also tried other variations

cmdAdd.Connection = conUserInfo

cmdAdd.ExecuteNonQuery()

conUserInfo.Close()
 
R

Robin Tucker

Don't quote me but I think "VALUES" must have brackets, ie.

INSERT INTO This VALUES (that1, that2, that3, that4)
 
A

Armin Zingler

Paul Mars said:
I think it is my SQL code that is causing the failure here. I receive
"An unhandled exception of type 'System.Data.OleDb.OleDbException'
occurred in system.data.dll" on the second to last line below. What's
wrong?

No solution but some hints:
- use Try/Catch block to catch and examine the exception
- use Parameters wherever possible (cmdAdd.Parameters)
- There's a group for ADO.Net questions:
microsoft.public.dotnet.framework.adonet


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
P

Paul Mars

Thank you Robin. I have been stuck for days on this. I had tried the
brackets before. What I was missing was "INTO". Now it works and I m so very
happy. !!!

thanks again !

Paul
 
S

SiD`

Paul said:
I think it is my SQL code that is causing the failure here. I receive "An
unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in
system.data.dll" on the second to last line below. What's wrong?

to know wats wrong use:

try
...
code
...
catch myODBCexception as odbcexception
console.writeline myodbcexception.message
end try
 

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

Top