Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 5th, 2003, 08:47 PM
soonercrazy soonercrazy is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 4 soonercrazy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Syntax error in INSERT INTO statement.

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.

Reply With Quote
  #2  
Old November 5th, 2003, 09:32 PM
rycamor rycamor is offline
Gödelian monster
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 1999
Location: Pembroke Pines, Florida, USA
Posts: 2,300 rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 3 h 12 m 27 sec
Reputation Power: 53
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

Reply With Quote
  #3  
Old November 5th, 2003, 09:54 PM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 17,653 r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 6 Days 12 h 34 m 33 sec
Reputation Power: 981
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/

Reply With Quote
  #4  
Old November 5th, 2003, 10:48 PM
soonercrazy soonercrazy is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 4 soonercrazy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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!!

Reply With Quote
  #5  
Old November 5th, 2003, 10:51 PM
soonercrazy soonercrazy is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 4 soonercrazy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #6  
Old November 6th, 2003, 05:38 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 17,653 r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 6 Days 12 h 34 m 33 sec
Reputation Power: 981
dates as strings?

remember what Einstein said: makes things as simple as possible, but no simpler!

Reply With Quote
  #7  
Old November 6th, 2003, 09:51 AM
rycamor rycamor is offline
Gödelian monster
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 1999
Location: Pembroke Pines, Florida, USA
Posts: 2,300 rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 3 h 12 m 27 sec
Reputation Power: 53
Quote:
Originally posted by r937
dates as strings?

remember what Einstein said: makes things as simple as possible, but no simpler!




Listen to the man, soonercrazy. You are asking for serious business logic problems later.

Reply With Quote
  #8  
Old November 6th, 2003, 05:21 PM
soonercrazy soonercrazy is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 4 soonercrazy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.....

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > Syntax error in INSERT INTO statement.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway