Error In INSERT INTO Statemanet
Jan 8, 2006
This is my code:
<%
dim connection
dim sSQL,sConnString, cat, compname, contactname, phone1, phone2, fax, address1, address2, city, state, zip, email, website, desc
cat = (Request.Form("cat"))
CompName = (Request.Form("CompName"))
ContactName = (Request.Form("ContactName"))
Phone1 = (Request.Form("Phone1"))
Phone2 = (Request.Form("Phone2"))
Fax = (Request.Form("Fax"))
Address1 = (Request.Form("Address1"))
Address2 = (Request.Form("Address2"))
City = (Request.Form("City"))
State = (Request.Form("State"))
Zip = (Request.Form("Zip"))
Email = (Request.Form("Email"))
Website = (Request.Form("Website"))
Desc = (Request.Form("Desc"))
'declare SQL statement that will query the database
sSQL="INSERT INTO Members (cat, CompName, ContactName, Phone1, Phone2, Fax, Address1, Address2, City, State, Zip, Email, Website, Desc) VALUES ('" & cat & "',' " & CompName & "', '" & ContactName & "', '" & Phone1 & "', '" & Phone2 & "', '" & Fax & "', '" & Address1 & "', '" & Address2 & "', '" & City & "', '" & State & "', '" & Zip & "', '" & Email & "', '" & Website & "', '" & Desc & "')"
'define the connection string, specify database
' driver and the location of database
sConnString="DRIVER={Microsoft Access Driver (*.mdb)};" & _
"DBQ=" & Server.MapPath("../db/gcdb404.mdb") & ";"
'create an ADO connection object
Set connection = Server.CreateObject("ADODB.Connection")
'Open the connection to the database
connection.Open(sConnString)
'execute the SQL
connection.execute(sSQL) (LINE 37)
'check to see if there were any errors
If err.number=0 Then
response.redirect ("member_admin.asp?action=list")
End If
'close the object and free up resources
Connection.Close
Set Connection = Nothing
%>
I get this as an error:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
/gcchamber/admin/addtodb.asp, line 37
Line 37 being: connection.execute(sSQL)
I have been attempting to fix the problem for hours. Can anyone please help?
Thanks...
View Replies
ADVERTISEMENT
Nov 2, 2006
Hi Forum,
I am working on a little database and I have the code shown below. When I run it, I get the following error message:
Syntax error in query. Incomplete query clause.
Here is the code:
Dim cpyText As String
Dim sqlStatement As String
Dim newName As String
cpyText = List11.Column(0, List11.ListIndex)
fld_lname.SetFocus
newName = fld_lname.Text
sqlStatement = "INSERT INTO '" & newName & "' ([perm]) VALUES ('" & cpyText & "')"
DoCmd.RunSQL (sqlStatement)
The sql statement is on one line...it just wrapped in this window.
In the debug window, the values of the variables in the sqlStatement are what I expect them to be. So I cannot figure out why I am getting the error.
Any assistance is greatly appreciated.
Mike
View 2 Replies
View Related
Oct 30, 2005
Hello All,
I'm am writing an App in Java connecting to an MS Access database. I am now getting a syntax error on the following insert into statement:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
source = "jdbc:odbc:DKOperations";
connection = DriverManager.getConnection(source);
Statement stmt = connection.createStatement();
String CustInfoTable = "CUSTOMER_INFORMATION";
stmt.executeUpdate("INSERT INTO " + CustInfoTable + " CUSTOMER_FIRST_NAME VALUES " + CustFirstName);
This is the error:
An SQLException occurred: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
I cannot figure out what the syntax error is. Anyone have an insight on this for me? Most likely something easy that I am missing.
Thanks!
View 1 Replies
View Related
Apr 2, 2008
Hi
This may be a very silly question but I have the following code which is meant to take data from textboxes, checkboxes etc and insert it into a new record on a table using the INSERT INTO statment. However I am getting a Syntax error in my INSERT INTO statement which i cannot figure out.
Please Help!!?
Private Sub cmdSaveRecord_Click()
Dim SQL As String
Dim Today As String
Dim Ref As String
Dim HK As String
Dim Site As String
Dim Equip As String
Dim Serial As String
Dim Invoice As String
Dim Client As String
Dim HKRef As String
Dim Tested As String
Dim Completed As String
Dim chkHKr As String
Dim Repaired As String
Dim Spares As String
Dim CompDate As String
Dim Exp As String
Today = txtDate
Ref = txtRef
HK = txtHK
Site = txtSite
Equip = txtEquipment
Serial = txtSerial
Invoice = txtInvoice
If cboClient.Column(0) <> Null Then Client = cboClient.Column(0) Else Client = ""
HKRef = txtHKRef
Tested = chkTested.Value
Completed = chkCompleted.Value
chkHKr = chkHK.Value
Repaired = chkRepaired.Value
Spares = chkSpares.Value
CompDate = cldComp.Value
Exp = cldExp.Value
SQL = "INSERT INTO ServiceReport (Date, CallReferenceNo, HongKongFaultNo, Client, Site, Equipment, SerialNo, Tested, Repaired, Spares, HK, ExpectedDate, Completed, InvoiceNo, CompletedDate VALUES (Today, Ref, HK, Site, Equip, Serial, Invoice, Client, HKRef, Tested, Completed, chkHKr, Repaired, Spares, CompDate, Exp)"
DoCmd.RunSQL SQL
View 5 Replies
View Related
Nov 2, 2005
I`m trying to insert some rows of the table [Produse finite dbo_SC03XX00] into the table [Loturi dbo_SC33XX00].
So, I tryed to run the following queries:
A) INSERT INTO [Loturi dbo_SC33XX00] ( [Loturi dbo_SC33XX00].SC33001, [Loturi dbo_SC33XX00].SC33002, [Loturi dbo_SC33XX00].SC33003, [Loturi dbo_SC33XX00].SC33005)
VALUES (select [Produse finite dbo_SC03XX00].SC03001,'01','000000000999',5000 from [Produse finite dbo_SC03XX00]);
But, when I want to save the query I get the following error:
"Syntax error. in query expression 'select [Produse finite dbo_SC03XX00].SC03001'"
B) INSERT INTO [Loturi dbo_SC33XX00] ( [Loturi dbo_SC33XX00].SC33001, [Loturi dbo_SC33XX00].SC33002, [Loturi dbo_SC33XX00].SC33003, [Loturi dbo_SC33XX00].SC33005)
VALUES select [Produse finite dbo_SC03XX00].SC03001,'01','000000000999',5000 from [Produse finite dbo_SC03XX00];
and I get the error:
"Syntax error in INSERT INTO statement."
I thought that the select query might be wrong, so I tested it:
"select [Produse finite dbo_SC03XX00].SC03001,'01','000000000999',5000 from [Produse finite dbo_SC03XX00]"
and it runs correctly.
How can I solve the problem? How can I insert the specified rows from the table [Produse finite dbo_SC03XX00] into the table [Loturi dbo_SC33XX00]?
Thank you in advance.
View 1 Replies
View Related
Jan 9, 2007
Hi,
I was wondering if i could get some help here. I got error message saying "user defined - typed not defined" and it's highlighting the first line that is WorkBase as Database.
Here is my code.
Dim WorkBase As Database
Dim WorkRS1 As Recordset
Dim rsNew As New ADODB.Recordset
Set WorkBase = CurrentDb
strSQL = "INSERT INTO [Projects](Project_ID, [OLD J_ID]) "
strSQL = strSQL + "VALUES ('" & myProjectID & "', '" & myOldPID & "')"
WorkBase.Execute strSQL, dbFailOnError
WorkBase.Close
This is for Office 2003
Thank you in advance
View 1 Replies
View Related
Sep 27, 2005
I keep getting the error Syntax Error in INSERT into statement. I don't know why
This is the sql statement:
Dim intRequest As Integer
Dim intRequest2 As Integer
Dim strSQL As String
Dim intInvoiceNumber As Integer
Dim strInvoiceDate As String
Dim strName As String
Dim intBalanceDue As Double
repeats:
If Paid.Value = -1 Then
intRequest = MsgBox("Now that you have checked this as been paid, do you wish to finalize this and become irreversable? (If you want further help about this click the Cancel button)", vbInformation + vbYesNoCancel)
If vbNo = intRequest Then
cancellation:
Paid.Value = 0
Call MsgBox("Request cancelled.", vbInformation)
Exit Sub
ElseIf vbYes = intRequest Then
' Perform action here
Invoice_Number.Enabled = True
Invoice_Number.SetFocus
intInvoiceNumber = Val(Invoice_Number.Text)
Invoice_Date.SetFocus
Invoice_Number.Enabled = False
strInvoiceDate = Invoice_Date.Text
Bill_To_Name.SetFocus
strName = Bill_To_Name.Text
strSQL = "INSERT INTO Paid-Address (Invoice-Number, Invoice-Date, Name, Balance-Due) VALUES ('" & Val(intInvoiceNumber) & "','" & strInvoiceDate & "','" & strName & "','32')"
Invoice_Number.Enabled = False
MsgBox (strSQL)
DoCmd.RunSQL strSQL
Else
intRequest2 = MsgBox("You have checked this invoice to be paid but if you don't finalize it, it be assumed an error or the cheque has bounced. If you finalize it in the other hand this invoice will be permenantly deleted from this record and entered into the paid summary instead. Do you wish to return back to the request message or do permenant cancellation?", vbInformation + vbYesNo)
If intRequest2 = vbYes Then GoTo repeats
GoTo cancellation
End If
End If
View 7 Replies
View Related
Mar 22, 2007
This is a simple code for inserting values to database.But I'm getting syntax error in the insert statement.I'm attaching the code for reference.Do help me out
Regards
Ransha
Dim mail,Login,password,conn,strSql
Login=Request.Form("name")
password=Request.Form("password")
mail=Request.Form("email")
'Creating connection Object
Set conn=Server.CreateObject("ADODB.Connection")
conn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=C:/example/login.mdb"
strSql = "INSERT INTO Names (UserName, Password, Email) VALUES ('"&Login&"','"&password&"','"&mail&"')"
conn.Execute(strSql)
conn.Close
Set conn=nothing
View 3 Replies
View Related
Oct 7, 2007
Can anyone tell me what is wrong with this statement. I get the error "Syntax error in INSERT INTO statement". I am the worst kind of user as I did not write this database and am trying to learn on the fly. Any help is greatly appreciated.
This macro is supposed to insert an amount into an "Activity" record based on the Co_Default_Rate field setup in the CompanyInfo table.
INSERT INTO [FORMS]![Activity]![Amount] SELECT (CompanyInfo.Co_Default_Rate)
FROM CompanyInfo
WHERE CompanyInfo.Co_Number = [FORMS]![Installs]![Installs_Co_Number];
View 1 Replies
View Related
Feb 1, 2007
What is the syntax error in this Insert Into statement ?
INSERT INTO RawData(RunID,fullName,name,category,type,subType, numberOfLines,virtual,date,namespace) SELECT 257 ,fullName,name,category,type,subType,numberOfLines ,virtual,#1/3/2007#,namespace FROM RawData WHERE namespace ='customer.demo' AND RunID =256
View 2 Replies
View Related
Apr 13, 2005
Hello.
I've managed to create an access-database and (fill it with some data), retrieve data from it with asp, but
when I try to insert or update data with asp, I get the same error:
"Syntax-error in Insert expression" or "Syntax-error in update expression"
Do I have to "chmod" the database to write to it, or what?
(I usually work with sql-databases, and the code/syntax I believe is not wrong,as it works on another database)
Conn.Execute("INSERT INTO tour(date,venue,city,link) VALUES('" & datum & "','" & venue & "','" & city & "','" & link & "')")
Thank you in advanced for answering my query.
//Joakim
View 5 Replies
View Related
Apr 27, 2005
Hey, I have a problem with my application......when the user trying to insert string with apostrophe into txtDesc (text box), the code returns error...
Run-time error '3057'
the database inserts any records excellently, but not with the apostrophe....
here is my code:
Code:sql = "INSERT INTO M_Stock ([StockRef], [StockGroup], [Desc], [Location], [Category], [UOM], " & _ "[RQ], [Remark0], [Remark1], [Remark2]) " & _ "VALUES ('" & txtStockRef & "', '" & cmbSG & "', '" & txtDesc & "', '" & cmbLoc & "', " & _ "'" & cmbCat & "', '" & cmbUOM & "', '" & txtRQ & "', '" & txtRemark0 & "', " & _ "'" & txtRemark1 & "', '" & txtRemark2 & "');"Set dbs = CurrentDbdbs.Execute sql
Can someone help me with this problem? Thanks in advance
View 1 Replies
View Related
Jul 20, 2006
hi,
i am getting an error in my coding for a INSERT statement becasue the text of the field contain an apostrophe.
that is my code is
DoCmd.RunSQL "INSERT INTO tbl_StartEndDates_OVERHEAD ( Last_Name)" _ & "VALUES ('" & Forms!OverheadEmployeeDates!lblLast_Name & "');"
but the text in Forms!OverheadEmployeeDates!lblLast_Name is "D'Amereo".
I know that this works for all other Last_Names without an apostrophe in it
does any one know the correct coding for this?
thansk
tuk
View 3 Replies
View Related
Jun 11, 2013
Why I get a runtime 3134 error on this piece of code.
They are all text values
Code:
Dim strUserName As String
strUserName = Forms!FrmPrimaryData.FrmPrimaryDataInstallsSubFrm.Form.txtMacAddress
Dim strIDValue As String
strIDValue = Nz(DMax("[ID]", "radreply"), 0) + 1
Dim strAttribute As String
[Code] ....
View 6 Replies
View Related
Jan 22, 2014
I am having a problem with below and getting a run-time error 3134
Code:
LastOrderNumber = DMax("Order", "Model_types")
NewOrderNumber = CLng(LastOrderNumber + 1)
CurrentDb.Execute "INSERT INTO Model_types (Order) " _
& "VALUES (" & NewOrderNumber & ")"
The field 'Order' in Model_types is a Long Integer.
View 4 Replies
View Related
Jul 31, 2012
I'm trying to run the following query
INSERT INTO Enrolled_Students (Last Name, First Name, Address, town/city, county, postcode, phone number, date of birth, age)
SELECT Last Name, First Name, Address, Town/City, County, Postcode, Phone Number, Date of Birth, Age
From Candidate Details
Where IsNumeric (Student ID);
and i'm receiving the error stated above
what im doing wrong?
View 12 Replies
View Related
Jun 21, 2015
PHP Code:
Dim strSQL As String 'Add Absence Data to tblHour.
strSQL = "INSERT INTO tblHour (WorkDate,EmployeeID,Hours) "
strSQL = strSQL & "VALUES (#" & Me.AbsenceDteTo & "#, '" & Me.EmployeeID & "', '" & Me.txtAbsHrs & "')"
CurrentDb.Execute strSQL, dbFailOnError
[Code] ......
View 3 Replies
View Related
Jun 15, 2013
I am trying to insert a new line below the active cell ive tried several attempts but i am getting error 1004. Some attempts are commented out.
Code:
wks6.Activate
With wks6
.Select
' .Rows.AutoFit
' .Columns.AutoFit
.Range("A:AO").Select
[Code] .....
View 6 Replies
View Related
Mar 13, 2015
I am getting a syntax error on my SQL statement.
On a form I have a sub form containing the field txtGuestID - whose control source is GuestID.
On the main form I have a button that fires the code below.
I am sure I am not referring to the control txtGuestID correctly.
Code:
Private Sub cmdInbound_Transport_Click()
Dim iProductID As Integer
Dim sSQL As String
On Error GoTo cmdInbound_Transport_Err
[Code] ....
View 6 Replies
View Related
Oct 23, 2014
I am building an access database for my college project and I essentially have a quotation form that when I click a button 'Convert to Invoice' it creates a new record in the invoice table and then creates new records in the invoice details table which match the quotation details table. This is working as it should but for only the first 2 customers in my customer table?
On the quote form I have a combo box which is linked to the customer table and updates the quote table based on the selection. If I select customer 1 or 2 and click 'convert to invoice' it works and opens an invoice form based on the inserted data however if I select any other customer it returns an error that the record wasn't added to the table due to key violations?
As far as I can tell I am not trying to update the primary keys in the Invoice Table or the Invoice Details Tables.
View 1 Replies
View Related
Oct 11, 2014
I use before insert code procedure to insert default value for one, or more fields in row. It is normal to have these fields are disabled. This event occurs when you try to enter a value in any another field in a row. However , when I finish entering the field going to the event before update regardless and trigger a validation of all fields in a row. I am not leaving from row , I want to go further input in other fields.How to insert default (calculated) values in new row.
View 2 Replies
View Related
Dec 4, 2013
I am trying to create an INSERT statement from a form to put unbound fields in a table. The challenge that I am a getting is that I am getting a
Run-time error '3075' Syntax error in date in query expression '#'
What is really perplexing and perhaps something that may guide in identifying the culprit is that I have an identifcal form that uses the identical code and it works.
Here is the code below:
Dim strSQL As String
Dim strCriteria As String
strSQL = ""
strSQL = strSQL & " INSERT INTO [tblTicket]"
[Code] ....
View 4 Replies
View Related
Sep 19, 2004
I try to do an INSERT statement throught my ASP to add records to my Access DB. However I get an error when I execute this. The code in ASP is -
Code: strSQL = "INSERT INTO tbl_psm (LocID, Week, Month, Year, Rating, Remark, Action, SubmittedDateTime) VALUES ('" &cint(intLocid)& "', '" &cint(sWeek)& "', '" &cint(sMonth)& "', '" &cint(sYear)& "', '" &cint(sRating)& "', '" &sRemark& "', '" &sAction& "', '" &formatdatetime(date,vbshortdate)& "');" objConn.Execute strSQL
I get the error page -
Microsoft JET Database Engineerror '80040e14'
Syntax error in INSERT INTO statement. /PeriodicWorkScheduleRatingSubmit.asp, line 65
I tried doing a response.write onto the ASP (to get the actual SQL), got the query, copy-pasted it and ran it on MS Access - it worked fine there. The query is -
Code: INSERT INTO tbl_psm (LocID, Week, Month, Year, Rating, Remark, Action, SubmittedDateTime) VALUES ('50', '2', '9', '2004', '3', 'asd', 'asdasd', '9/20/2004');
I can't understand if it works in Access, who not work through ASP?? Is there somethings wrong somewhere? I cannot see it..
Please help..
View 2 Replies
View Related
Aug 28, 2014
I am at work, and I have acquired a database that prints labels. They now want the database to be coded so that after certain labels are printed the database will print a blank label. I have the code figured out as a Do While statement in order to print the blank label. The problem I am having is that I am trying to use the Insert Into command to insert the filepath into the table that adds the blank label.
|DoCmd.RunSQL "INSERT INTO Rod_tmakLabels ( Print, [Order] ) SELECT Yes AS Expr1, 'Rods Labels' AS Expr2"|
If I run the above command, it just adds the text "Rods Labels" at the end of the table. Is there anyway with the INSERT INTO command that I can insert the new label between the 2nd and 3rd row and add another row? Or is the command designed only to add a new row to the end? I haven't had any luck searching for this yet.
View 1 Replies
View Related
Jul 2, 2010
Table TBL_NEWDATA is used to append new data to table TBL_PERSON_ALLOCATIONS.
TBL_NEWDATA { Person_ID, Department_ID }
TBL_PERSON_ALLOCATIONS { Person_ID, Department_ID, ... }
I need to devise a query to append data for a particular Department_ID from TBL_NEWDATA to TBL_PERSON_ALLOCATIONS where that data does not already exist there. i.e. for Department_ID 'Research', I would want to append 'Person_ID', 'Department_ID' (in this case: 'Research') to TBL_PERSON_ALLOCATIONS for any tuples not already held.
INSERT INTO TBL_PERSON_ALLOCATIONS (Person_ID, Department_ID)
SELECT Person_ID, Department_ID
FROM TBL_NEWDATA
WHERE TBL_NEWDATA.Department_ID='Form...'
[code]...
This Query takes a single argument from a control (Forms!Main!IN_Department), and this is the Department_ID to be updated.Is there any way to do this using a single query or will I have to use sub queries? I'd hoped not to as to keep the database as concise as possible.
View 2 Replies
View Related
Mar 25, 2015
I have a normalized DB with one to many relationships, using Primary and Foreign Keys.
I need to do inserts and maintain the PK/FK relationship, which means when I add a new PK I need to insert that PK as FK in other tables in the same transaction.
How do I do this in Access? SQL Server I use transactions, but I can't lock up the tables in Access like that.
I did a bunch of searching and found nothing, which leads me to believe I am way off in my thinking. Below are the dirty details
I have 2 tables, tblName and tblPhone. 1 name can have many phones.
tblName has PKName. tblPhone has PKPhone, FKName.
I have a form where user enters a new Name and PhoneNumber.
Name gets inserted to tblName, assigned with PKName = 100
Phone should get inserted into tblPhone with PKName.
IE Insert into tblPhone (FKName, PhoneNum) VALUES (100,"212-555-1212").
The dumb way I am doing it now is I insert to tblName, query tblname for the PK, then write to tblPhone. This can't be right.
View 2 Replies
View Related