April 17, 2024, 10:22:27 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Help!

Started by Andy, June 12, 2018, 05:50:59 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

June 12, 2018, 05:50:59 AM Last Edit: June 12, 2018, 05:52:32 AM by Andy
Why can I not even add a blank record to this DB!

The table is created correctly:


iStmt="CREATE TABLE customers (addrid counter(1,1),recID int,fName varchar(40),lName varchar(40),"
iStmt+="street varchar(40),city varchar(40),region varchar(40),"
iStmt+="postcode varchar(9),phone varchar(40),mobile varchar(40),facebook varchar(40),"
iStmt+="work varchar(40),notes varchar(255),cphoto varchar(255),dateChanged date)"
hStmt=dbExecSQL(pDB,iStmt)


But I can't create a blank record:


iStmt="INSERT INTO customers (recID,fName,lName,street,city,region,"
iStmt+="postcode,phone,mobile,facebook,work,notes,cphoto,dateChanged) "
iStmt+="VALUES("+STR$(id)+",'new','new','','','','','','','','','','','')"
hStmt=dbExecSQL(pDB,iStmt)
temp=dbGetErrorCode(hStmt)


:P

Error 420000?

Andy.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Brian

Andy,

Are you setting id with a value? Put "INT id=1" before the SQL. Can't tell without your full code, really, what you are doing

Brian

Andy

Brian,

Did that, now I get a different error - data type mismatch.

The last field is a date field, and I'm setting it to "" - what should it be?

Thanks,
Andy.

Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Andy

Brian, I knocked out the date field and it works! thanks, but how do I set a blank date field?

Andy.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

billhsln

June 12, 2018, 09:08:08 AM #4 Last Edit: June 12, 2018, 09:10:24 AM by billhsln
Easy way is to leave it out of the list and it will default to today's date, at least it should, it will probably show as blank in ACCESS.  I would redo the INSERT like:

iStmt="INSERT INTO customers (recID,fName,lName) VALUES("+STR$(id)+",'new','new')"

Bill
When all else fails, get a bigger hammer.

Andy

Thanks bill,

I will bare that in mind!

Andy.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.