Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Syntax Error in INSERT INTO Statement

Posted on 2004-10-26
2
Medium Priority
?
237 Views
Last Modified: 2010-04-15
I am trying to insert data into an Access database using C# in a Windows App.  I keep getting a syntax error on this  sql statement telling me a ';' is expected at the end of the statement.  I put extra ; in and get the same error.  All other surrounding code has the proper ';'.  

string strSQLSelect1 = "INSERT INTO [Import] ([timeStamp], DocumentName, DocumentType, TransactionType,TANUM)  " +
      "VALUES( " + @timeStamp, @DocumentName, @DocumentType, @TransactionType, @TANUM +" )";

ptslv
0
Comment
Question by:ptslv
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 15

Accepted Solution

by:
SRigney earned 375 total points
ID: 12414926
Access Queries themselves expect to end in a semicolon, and you need to fill in the values for you query.

Try this:

string strSQLSelect1 =
  String.Format("INSERT INTO [Import] ([timeStamp], DocumentName, DocumentType, TransactionType,TANUM) VALUES( {0}, {1}, {2}, {3}, {4}, {5});", timeStamp, DocumentName, DocumentType, TransactionType, TANUM );

Make sure that you are using the correct variables that hold to values for
timeStamp, DocumentName, DocumentType, TransactionType, TANUM
0
 

Author Comment

by:ptslv
ID: 12415032
Thanks, SRigney.  But I already trashed this version because it worked without the Insert Into query.  I was having other problems that prompted me to go this route.  However, since you responded before I cancelled the question, I will give you the points.  If you want more, just see my next question!  ;-)

ptslv
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question