Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 3rd, 2008, 11:14 AM
Authorized User
 
Join Date: Nov 2008
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default .net sql

Hello,
I'm trying to run a simple sql command
and always get an insert error!
syntax runs good in Access, but iis throws exeption.

code:

Sub button1_click1(ByVal Source As Object, ByVal E As EventArgs)

        Dim dbconn, dbcom
        dbconn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; data source=" & Server.MapPath("db.mdb"))
        dbconn.open()


        Dim sql As String = "INSERT INTO user([Fname[,[Lname],[email],[Country]) VALUES (nnnn,'T','[email protected]',us);"


        dbcom = New OleDbCommand(sql, dbconn)

        dbcom.ExecuteNonQuery()




[u]error</u>:

Syntax error in INSERT INTO statement.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement.

Source Error:


Line 19: dbcom = New OleDbCommand(sql, dbconn)
Line 20:
Line 21: dbcom.ExecuteNonQuery


any suggestions?
thank u
 
Old November 3rd, 2008, 11:42 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hi there.. Fname has a bad closing ].. and if nnnn and us are string, should be around '...

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old November 3rd, 2008, 12:01 PM
Authorized User
 
Join Date: Nov 2008
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi there, thank you

i changed to this: but still "Insert Error" (IIS with .net engine)
 Dim dbconn, dbcom
        dbconn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; data source=" & Server.MapPath("db.mdb"))
        dbconn.open()


        Dim sql As String = "INSERT INTO user([Fname],[Lname],[email],[Country]) VALUES ('Doronnn','T','[email protected]','us');"


        dbcom = New OleDbCommand(sql, dbconn)

        dbcom.ExecuteNonQuery()



Quote:
quote:Originally posted by gbianchi
 Hi there.. Fname has a bad closing ].. and if nnnn and us are string, should be around '...

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old November 3rd, 2008, 12:55 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Did you try that exact query in the DB?

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old November 3rd, 2008, 04:00 PM
Authorized User
 
Join Date: Nov 2008
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

yes it works fine in db

Quote:
quote:Originally posted by gbianchi
 Did you try that exact query in the DB?

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old November 3rd, 2008, 04:04 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

User is a reserved word, so you can't "insert" into that .

Try renaming the table to SiteUsers or whatever users the table contains.

Cheers,

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
 
Old November 3rd, 2008, 06:33 PM
Authorized User
 
Join Date: Nov 2008
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thank you !!
it worked !

thanks alot

Quote:
quote:Originally posted by Imar
 User is a reserved word, so you can't "insert" into that .

Try renaming the table to SiteUsers or whatever users the table contains.

Cheers,

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.





Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET 1.1,VB.NET,crystal reports, SQl server gvi Crystal Reports 1 September 11th, 2008 02:55 AM
SQL Server with ADO.NET dounme SQL Server 2000 4 February 8th, 2005 09:19 PM
Displaying SQL Report in VS.Net exactlynn SQL Server 2000 0 July 29th, 2004 06:32 AM
MSDE and SQL CE (using VB.NET and ADO.NET) LEGS ADO.NET 0 July 12th, 2003 11:27 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.