Hi friends,
I am facing this error in my vb 6.0 code.
The code is... - Dim conn As New ADODB.Connection
-
Dim cmd As New ADODB.Command
-
-
-
Private Sub cmdOK_Click()
-
-
conn.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=F:\VB Progs\Cafe\Cafe.mdb;"
-
-
conn.Open
-
-
cmd.ActiveConnection = conn
-
conn.CursorLocation = adUseClient
-
-
cmd.CommandText = "Insert into Session (UserId) values ('" & txtUserName.Text & "')"
-
-
MsgBox cmd.CommandText
-
-
cmd.Execute
-
-
conn.Close
-
-
End Sub
When executed, it gives an error message saying...
Run-time error '-2147217900(80040e14)':
Syntax Error in INSERT INTO Statement
Please help.
9 5819
Without knowing more about your table and the contents of the textbox it's hard to say for sure. But perhaps your name field had an apostrophe in it? You know, like "O'Reilly" or something. Since the apostrophe character is used to delimit the field, this might confuse the database engine.
Without knowing more about your table and the contents of the textbox it's hard to say for sure. But perhaps your name field had an apostrophe in it? You know, like "O'Reilly" or something. Since the apostrophe character is used to delimit the field, this might confuse the database engine.
Hi
There is no such problem with my textbox "txtName".
When I display the command text in a msgbox, it shows Insert into Session(UserId) values('test')
And about the table,
Table name is Session with fields,
SessionID Autonumber
UserID Text 50
UserName Text 50
and so on.
I don't think other fields are relevent here.
I don't know what's wrong.
I'm going to refer this to the Access forum, as my SQL is somewhat "rusty". (Just for future reference, this originated in the VB forum.)
The only thing I can think of is that perhaps some other field (such as UserName) is mandatory and the "syntax error" actually means that you left out a required field. I'm sure the SQL experts in the Access forum will have a better idea of what's going on.
Thank you very muchh for your concern.
By the way i have only a SessionID field that is Autonumber
that happens to be required (& Primery Key). All other fields have
no constraints.
Anywayz thank you once again.
hope to get some help from access community as well.
NeoPa 32,556
Expert Mod 16PB
Hi sudhanshu.
Did you get : Insert into Session(UserId) values('test')
or Insert into Session (UserId) values ('test')?
Try formulating it as : - INSERT INTO [Session] ([UserId]) VALUES ('test')
and see what it says.
Please post your results precisely in the post as misquotes can waste a lot of time.
Good luck.
Did you get : Insert into Session(UserId) values('test')
or Insert into Session (UserId) values ('test')?
So the space is significant, then? I wondered about it, but I'm not that familiar with the INSERT syntax yet.
NeoPa 32,556
Expert Mod 16PB
I'd be surprised if it were, but the results as posted were not as expected and I want to make sure we're not dealing with misinterpretations etc before continuing. So much time is wasted chasing leads that turn out simply to be slapdash posts by the OP. The square brackets ([ & ]) ensure we're not falling over any reserved words.
Hi NeoPa & Killer42
thank you very much both of you. It worked.
Perhaps I have field names which are keywords.
I had no idea abt this.
I dont know how I've been using such fieldnames
before without having a problem.
Anyways thank you once again for your concern.
NeoPa 32,556
Expert Mod 16PB
It may not have been reserved words. Often simply going through the code carefully fixes bugs you don't even notice.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Gérard Leclercq |
last post by:
ACCESS
First fields are TEXT, last 2 are Numbers
The name of the fields are correct.
Dim MyConn
Set MyConn=Server.CreateObject("ADODB.Connection")
MyConn.Open...
|
by: dcarson |
last post by:
I've read about this error in several other discussions, but still
can't seem to pinpoint the problem with my code. Everything seemed to
be working fine for some time, but it now tends to bomb out...
|
by: William |
last post by:
i am using a dataset and a DataAdapter to update a table with the
following schema:
ResourceID
ProjectID
LastName
FirstName
Year
Nov
Dec
Jan
|
by: kosta |
last post by:
hello! one of my forms communicates with a database, and is
supposed to add a row to a table using an Insert
statement... however, I get a 'oledb - syntax error'
exception... I have double...
|
by: eric dugal |
last post by:
Hi all!!
I need your help.... i'm working since 2 hours on a simple insert statement,
but couldn't handle it.
Here is my code :
public int ExecQuery(string SqlString)
{
|
by: Neil Zanella |
last post by:
Hello,
I am trying to execute ADO.NET INSERT statement where one of the
fields
is coming from a password HTML control. When I access the text with
password.Value and print with Response.Write...
|
by: Nathan Sokalski |
last post by:
When trying to submit data to an Access database using ASP.NET I recieve the
following error:
System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr)
+41...
|
by: amitbadgi |
last post by:
Hi guys, I am getting the following error in teh insert statement , I
am converting this asp application to asp.net, here is teh error,
Exception Details:...
|
by: RSH |
last post by:
I have a rather simple script that transfers data from a SQL server database
to an Access database. The procedure is intended to be dynamic so I am
basically adding a datarow and then passing the...
|
by: ewpatton |
last post by:
Good day,
I've been trying to work with SQL and an Access database in order to
handle custom user profiles. I haven't had any trouble reading from my
database, but inserting new entries into...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
| |