adeelehsan:Because USERS may be a reserve word or reserve name of an existing object.
No it is not (USER is). The complete list of Jet (in an ASP.NET environment we're dealing with a Jet Database Engine) can be found here
papabear:Basically you need to specify the parameters using the @
No, that's not required. Jet will thread any unknown string as a parameter. Off course, it is a good habit using @
papabear:then refer to them on the InsertParameters section...
Be aware that when using OleDB, parameters are not recognized by their name, but by their position. So the parameters must be addes in the parametercollection in the same order they appear in the sql string.
SqlDataSource1.InsertParameters.Add("Paremeter1", Me.Account.Text)
SqlDataSource1.InsertParameters.Add("Paremeter2 Or any other name, even an empty string will do", Me.AccountName.Text)
is OK
SqlDataSource1.InsertParameters.Add("@ACCOUNTNAME", Me.AccountName.Text)
SqlDataSource1.InsertParameters.Add("@ACCOUNTID", Me.Account.Text)
is NOT OK
FrankEnem:SqlDataSource1.InsertCommand = "Insert INTO USERS (ACCOUNTID, ACCOUNTNAME)" & _
"Values(01011,Accounts Payable)"
SqlDataSource1.UpdateParameters.Clear()
SqlDataSource1.InsertParameters.Add("ACCOUNTID", Me.Account.Text)
SqlDataSource1.InsertParameters.Add("ACCOUNTNAME", Me.AccountName.Text)
In this case the first 'parameter' isn't threaded as a parameter, because it is a numeric value. Furthurmore, parameters may not have spaces in them. If you have parameters (or field or tablenames) with spaces, or you're using Reserved words, you should enclose them in brackets, like [Accounts Payable]. Change the code as papabear showed you and it should work