syntax error in INSERT INTO statement
- From: hariharan.priya@xxxxxxxxx
- Date: 24 Oct 2006 06:17:02 -0700
Hi all,
I am trying to create, and write data into microsoft access file using
CDaoDatabase and CDaoRecordset in Microsoft visual studio 8.0. I am new
to working with databases.
It is actually a example code from a website. The code is,
CDaoDatabase database;
CDaoRecordset recordset(&database);
CString lpszFile = "C:\\Database.mdb";
database.Create(lpszFile);
//database.Open(lpszFile);
_ASSERTE( _CrtCheckMemory( ) );
CString SqlCmd ="CREATE TABLE MINECOORDINATES (X VARCHAR(10)"
", Y VARCHAR(10)"
", Z VARCHAR(10))" ;
database.Execute(SqlCmd);
recordset.Open(AFX_DAO_USE_DEFAULT_TYPE,
"SELECT * FROM MineCoordinates", 0);
database.Execute("INSERT INTO MineCoordinates(X);");
database.Execute("INSERT INTO MineCoordinates(Y);");
database.Execute("INSERT INTO MineCoordinates(Z);");
recordset.AddNew();
recordset.SetFieldValue("X","10");
recordset.SetFieldValue("Y","13");
recordset.SetFieldValue("Z","13");
recordset.Update();
recordset.MoveNext();
recordset.AddNew();
recordset.SetFieldValue("X","11");
recordset.SetFieldValue("Y","1");
recordset.SetFieldValue("Z","3");
recordset.Update(); */
COleVariant olevar;
while(!recordset.IsEOF());
{
olevar.ChangeType(VT_BSTR, NULL);
recordset.GetFieldValue("X",olevar);
CString strData = (LPCSTR)olevar.pbstrVal;
// Code for inserting data into a listbox, for example
recordset.MoveNext();
}
At the run time i get an error stating, syntax error in INSERT INTO
statement. Could anyone please let me know, what is the error here?
Thank you,
Priya
.
- Follow-Ups:
- Re: syntax error in INSERT INTO statement
- From: Tim Roberts
- Re: syntax error in INSERT INTO statement
- From: Mark Randall
- Re: syntax error in INSERT INTO statement
- Prev by Date: Re: Compiler bug with aligned members in virtuals + alloca() in VS
- Next by Date: Re: One spin control works, one doesn't!!!
- Previous by thread: GUI Feedback when positioning windows
- Next by thread: Re: syntax error in INSERT INTO statement
- Index(es):
Relevant Pages
|