|
-
May 29th, 2001, 10:48 PM
#1
Thread Starter
Junior Member
Adding a record to a Database?
Hi I'v been trying to insert a record to a database using this code:
Set editCmd = Server.CreateObject("ADODB.Command")
editCmd.ActiveConnection = "dsn=Message;"
editCmd.CommandText = "insert into Posts (Date_added,Name,Email,Subject,Text) values ('5/29/2001 8:00:24 PM','Stephen',' [email protected]','Test','Testing.') "
editCmd.Execute
editCmd.ActiveConnection.Close
to create a Message Board, but I always get this error :
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
/syt/BillBoard/Index.asp, line 91
I'm totaly clules why this is happening
Help!!!!!!!!!!!
-
May 29th, 2001, 10:53 PM
#2
Addicted Member
Shouldn't the date be in a form other than as a string surrounded by single quotes??
-
May 29th, 2001, 11:02 PM
#3
Thread Starter
Junior Member
I dont think " ", / or : are not alowed though.
-
May 29th, 2001, 11:12 PM
#4
PowerPoster
have you referenced all the needed references.
I.e ole driver etc.
-
May 29th, 2001, 11:50 PM
#5
Lively Member
hey dont worry
It is nothing more than a syntax error ,
So just use cdate before your date expression so that
you won't get error i think,
if you get error still
check the date expression using Isdate before inserting into database
hope it works
Bye
I respect love and lovers ,but it should be possesive .
I love friendship and friends but it should be true.
-
May 30th, 2001, 12:11 AM
#6
Lively Member
Hey again Aniz with another solution
Your sql fine ,it has no error,The main thing when your passing
a sql through Ado it doesn't accept the field names if it is a reserved word. Your sql has reserve word TEXT as a field name ,
When Ado finds this text as one of the field name it generates the error
first you go to the table and change the FIELDNAME TEXT to TTEXT
then just try the modified sql now
editcmd.CommandText = "insert into Posts (date_added,Name,Email,Subject,ttext) values ('5/29/2001 8:00:24 PM','Stephen','[email protected]','Test','Testing.') "
hope this helps much.
bye.
I respect love and lovers ,but it should be possesive .
I love friendship and friends but it should be true.
-
May 30th, 2001, 10:21 AM
#7
Thread Starter
Junior Member
-
May 30th, 2001, 10:28 AM
#8
Or rather than renaming the field, just use this (ie. put brackets around dodgy words):
Code:
editcmd.CommandText = "insert into Posts (date_added,Name,Email,Subject,[Text]) values ('5/29/2001 8:00:24 PM','Stephen','[email protected]','Test','Testing.')"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|