473,406 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

SQL Insert Into statement Syntax Error

I'm working on a simple form to database program but I keep encountering a syntax error with my SQL statement.

Since it's so long, I don't want to parameterize it, but I will if it's the only way...please don't suggest that first.

Expand|Select|Wrap|Line Numbers
  1. String strSQL = "INSERT INTO Grant (CFDAnum,ProgramTitle,DueDate,SubmitDate,Developer,Dept,ContactName,Phone,Email,AwardAmount,Match(Y/N),FundingType,FedGrantnum," +
  2.             "PassThru,GrantContactName,GrantPhone,GrantEmail,ImmediateGrantorAgency,AgencyContactName,AgencyContactPhone,AgencyContactEmail,NoticeofAwardDate,FYFunding, " +
  3.             "TermofAgreementDate,ExpirationDate,FSR1Due,FSR1Submit,FSR2Due,FSR2Submit,FSR3Due,FSR3Submit,FSR4Due,FSR4Submit,ReportingComplianceNotesandComments," +
  4.             "FiscalOrderDeadline,CouncilApproval,GrantCode,GrantDetail,Budget,FundCode,IndexCode,RevenueSubobject,1stQtrBal,2ndQtrBal,3rdQtrBal,4thQtrBal,YearEnd,Comments) " +
  5.             "VALUES('" + txtCFDA.Text + "','" + txtPrgrmTitle.Text + "','" + txtDueDate.Text + "','" + txtSubDate.Text + "','"
  6.                 + txtDev.Text +"','" + txtDept.Text + "','" + txtContactName.Text + "','" + txtDeptPhone.Text + "','" + txtDeptEmail.Text + "','" + txtAwardAmt.Text +
  7.                     "','" + txtMatch.Text + "','" + cboFundType.SelectedItem + "','" + txtFedGNum.Text + "','" + cboPassThru.SelectedItem + "','" + txtGrantContact.Text 
  8.                     + "','" + txtGrantPhone.Text + "','" + txtGrantEmail.Text + "','" + txtImmGrant.Text + "','" + txtAgntCntctName.Text + "','" + txtAgntPhone.Text +
  9.                     "','" + txtAgntEmail.Text + "','" + txtAwardDate.Text + "','" + txtFYFund.Text + "','" + txtAgreementDate.Text + "','" + txtExpireDate.Text
  10.                     + "','" + txtFSR1.Text + "','" + txtFSR1Sub.Text + "','" + txtFSR2.Text + "','" + txtFSR2Sub.Text + "','" + txtFSR3.Text + "','" + txtFSR3Sub.Text
  11.                     + "','" + txtFSR4.Text + "','" + txtFSR4Sub.Text + "','" + rtxReportComments.Text + "','" + txtFiscDead.Text + "','" + txtCouncApp.Text + "','"
  12.                     + txtGrantCode.Text + "','" + txtGrantDetail.Text + "','" + txtBudget.Text + "','" + txtFundcode.Text + "','" + txtIndexCode.Text + "','"
  13.                     + txtRevenue.Text + "','" + txt1stQtr.Text + "','" + txt2ndQtr.Text + "','" + txt3rdQtr.Text + "','" + txt4thQtr.Text + "','" + txtYearEnd.Text + "','" + rtxComments.Text + "');";

Edit: I just tried placing [] around all column names, no success.
Jul 8 '10 #1

✓ answered by improvcornartist

Does it work in smaller pieces? "Grant" may also be a keyword causing an error.

8 1573
improvcornartist
303 Expert 100+
Are you getting a specific syntax error?
Jul 8 '10 #2
Nope, it only supplies a "Syntax Error in INSERT INTO Statement" error message
Jul 8 '10 #3
improvcornartist
303 Expert 100+
If you print the completed strSQL, does it look okay? Any chance there is a type mismatch, such as trying to load text into an integer field, or a text value is too long for the database column?
Jul 8 '10 #4
Yea, I'm using numbers to test, but as you can see I have the ' 's to indicate text, all the columns are also text so there is no mismatch as far as I can tell.

I'm also using 1 and 2 digit numbers
Jul 8 '10 #5
improvcornartist
303 Expert 100+
Does it work in smaller pieces? "Grant" may also be a keyword causing an error.
Jul 8 '10 #6
I thought about attempting it in smaller pieces, thats my next move.

I saw a thread here from earlier where one of the suggestions was to query the database in access, im trying that now.
Jul 8 '10 #7
Bingo, turns out Grant must've been some keyword because its working now with grant in []

thanks a ton
Jul 8 '10 #8
improvcornartist
303 Expert 100+
Yeah, "grant" is used for giving privileges. Glad you got it working and that it turned out to be pretty simple.
Jul 8 '10 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: gregpinero | last post by:
It's the strangest thing, I'm pulling some text out of a MySQL table and trying to run exec on it, and it keeps giving me a syntax error, always at the end of the first line. Thanks in advance...
4
by: tasmontique | last post by:
Hello everyone, I keep getting a syntax error in my update statement. The only thing that I notice is that although the columns in my table have the same name as the fields on the form the...
2
by: kisalabs | last post by:
I have been trying to insert a new record into an access database and cannot get any of the scripts to work.. I can access the db and pull up/display records but cannot get one added. Please help. ...
1
by: vacuit | last post by:
Can you see where I am going wrong? 'SAVE THE RESULTS TO THE DATABASE Dim c_strAccessMDBFile As String = CStr(IBM.txtdblocation.Text) & "CrustaceanIBM.mdb" Dim...
8
by: OfficeDummy | last post by:
Hi everyone, I'm running SQL statement in my VBA code (importing an Excel file), but there seems to be a syntax mistake. I've googled and yahooed the Internet, but found nothing that applies to my...
6
by: patriciashoe | last post by:
I have been struggling with this update statement. At this point I get a syntax error if i go from SQL view to design view. Can anyone spot a problem? UPDATE teacherresources AS A SET...
3
by: shalskedar | last post by:
In my Db i need to update 3 columns..Below is my code to update but giving me an error...Can anyone Plz help me with this... str = "update set .='" & UserForm1.TextBox2.Text &...
9
by: Ed Pisa | last post by:
Hello, I have been working with this problem now for several days. I can delete and Update my data but I can not get it to insert a new record. I receive the syntax error insert into. I am not...
0
by: Ed Pisa | last post by:
Hello, I have been working with this problem now for several days. I can delete and Update my data but I can not get it to insert a new record. I receive the syntax error insert into. I am not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.