Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax error in INSERT INTO statement

Status
Not open for further replies.

zqtqzq

Programmer
Jul 23, 2003
61
A2
I have the following code in my webform
I have define my connection to an access Database(Ocnn)
Created an adapter oDa

strIns="Insert Into myTB(UserID,Pswd) Values(@UserId,@Pswd)
oCmd=new oledbCommand(strIns,Ocnn)
oDa.InsertCommand=oCmd

with ocmd
.parameters.Add(new oledbParameter ("@UserID",oledbtype.cahr,50)

.parameters.Add(new oledbParameter ("@Pswd",oledbtype.cahr,50)

.parameters("@UserID").value=txtID.Text.Trim
.parameters("@Pswd").value=txtPW.Text.Trim
end with
ocmd.ExecuteNonquery(0

after running my web form i keep receiving the error
error in INSERT INTO Statement

some times after trying other methods of getting this done i also receive the error

Operation must use an updateable query

pls help

tunde aransiola
 
You've got several typographical errors in your code, for instance:
Code:
oledbtype.cahr

Do you have option explicit and option strict turned on?

Chip H.



____________________________________________________________________
Donate to Katrina relief:
If you want to get the best response to a question, please read FAQ222-2244 first
 
I'm not sure about this, but maybe you need to add some spaces.
Try changing
Code:
strIns="Insert Into myTB(UserID,Pswd) Values(@UserId,@Pswd)"
to
Code:
strIns="Insert Into myTB (UserID,Pswd) Values (@UserId,@Pswd)"

Regards
 
the problem looks to be a missing ".
Take a look:
Code:
strIns="Insert Into myTB(UserID,Pswd) Values(@UserId,@Pswd)

You need the " at the end of this statement.

also you are missing a )
Take a look:
Code:
ocmd.ExecuteNonquery(0
 
I had once posted only one char: this -> " , meaning what ralp said, but somebody deleted my post. Anyway
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top