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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to Update MSAccess DB

Status
Not open for further replies.
Mar 4, 2003
47
US
I'm stuck. I've been trying to get this to work all day and can't seem to find the problem. I am trying to insert a row into an Access table with data from an asp.net page.

I have two drop-down lists and three text boxes on the page that the user will input data to. I generate a primary key off the count of the records to get the sixth value.

When I try to run the ExecuteNonQuery command I always get an error message saying "Syntax Error in SELECT INTO". Here is the code I'm using

Dim cmdStr As String = "INSERT INTO tblStats (StatID, WpnID, Min, Max, Spd, CreatorID) VALUES ('" & strStatKey & "','" & ddAddWpn.SelectedValue & "'," & CInt(txtAddMin.Text) & "," & CInt(txtAddMax.Text) & "," & CDbl(txtAddSpd.Text) & ",'" & ddAddCreator.SelectedValue & "')"

Dim cmdInsert As New OleDbCommand(cmdStr, OleDbConnection1)

OleDbConnection1.Open()
intAffected = cmdInsert.ExecuteNonQuery()
OleDbConnection1.Close()
MessageBox.Show("Number Affected: " & intAffected)

Thanks in advance...
 
Put the following code below the Dim cmdStr As String line

response.write(cmdStr)
response.end

Run the page. You will then see what your SQL insert statement looks like. If you can't figure why it is still bombing, paste the SQL to the forum so we can take a look. Also, I am not a fan of your primary key creation. Just AutoNumber it.
 
Actually just found it. Min and Max needed to be in brackets []. Guess they are reserved words that was throwing the system off. I'll remember that when I create my final database. This one has been mainly for testing purposes and proof of concept type stuff. Thanks for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top