|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I am using asp.net trying to update an access database. I've got my sql statement as follows
Dim strSQL as String strSQL = "" strSQL = strSQL & "INSERT INTO Customer " strSQL = strSQL & "(LAST, FIRST, C_MI, B_DATE, PHONE, USERID, PASSWORD) " strSQL = strSQL & "VALUES (" strSQL = strSQL & "'" & txtLast.Text & "'," strSQL = strSQL & "'" & txtFirst.Text & "'," strSQL = strSQL & "'" & txtMI.Text & "'," strSQL = strSQL & "'" & txtBirthDate.Text & "'," strSQL = strSQL & "'" & txtPhone.Text & "'," strSQL = strSQL & "'" & txtUsername.Text & "'," strSQL = strSQL & "'" & txtPassword.Text & "'" strSQL = strSQL & ")" I've stepped thru the code and I get hung on the ExecuteNonQuery statement. and then that's the error i get. I've checked the sql statement in access and it works fine, I just can't add from asp.net any help would greatly be appreciated. |
|
#2
|
|||
|
|||
|
1. Excuse my MS-ignorance here, but what is the ExecuteNonQuery function for? Is there an ExecuteQuery function? I'm not familiar with ASP.net, but my first reaction is "Why are we executing a non-query?" This looks like a query to me. Or is this just an unfortunately-named function for executing a standard SQL query?
2. Can you post an example of one of your actual generated insert strings? Most probably you have a simple escaping problem somewhere. You are outputting these statements for debugging purposes, right?
__________________
The real n-tier system: FreeBSD -> PostgreSQL -> [any_language] -> Apache -> Mozilla/XUL Amazon wishlist -- rycamor (at) gmail.com |
|
#3
|
||||
|
||||
|
don't dates in access require octothorp delimiters instead of singlequotes?
INSERT INTO Customer ( LAST, FIRST, C_MI, B_DATE, PHONE, USERID, PASSWORD) VALUES ( 'Schmoe','Joe','X.',#1953-05-07#,'555-01212','Joe','Please') rudy http://r937.com/ |
|
#4
|
|||
|
|||
|
the executenonquery is the general way of executing a insert in asp.net, But I thank you for your replys, I changed the database value names because I had a hunch that they might conflict and as soon as i did that wa la, it worked. Thank you again!!
|
|
#5
|
|||
|
|||
|
r937
You are right but my data types in my database are specified as strings so I didn't need to add the # sign to the query. I was making it as simple as possible. |
|
#6
|
||||
|
||||
|
dates as strings?
remember what Einstein said: makes things as simple as possible, but no simpler! |
|
#7
|
|||
|
|||
|
Quote:
![]() Listen to the man, soonercrazy. You are asking for serious business logic problems later. |
|
#8
|
|||
|
|||
|
I agree with you totally!! The only reason I had it done that way is that make everything the same, then easier to change and debug later.. I guess.....
|
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > Syntax error in INSERT INTO statement. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|