Database SQL INSERT 
Author Message
 Database SQL INSERT

I'm use VC++ with MFC's and this sentence build errors in the syntax.

Is this SQL sentence wrong...?

CString thecard = "342345";
long  theamount = 330;
CString theDate = "980606";

CString strc = "insert into account(card,amount,date)
values(thecard,theanount,thedate);

pdb->ExecuteSQL(strc);

Very Thanks!!!!!!
josep



Fri, 24 Nov 2000 03:00:00 GMT  
 Database SQL INSERT

You need to put single quotes around char and date datatypes.
CString thecard = "'342345'";
long  theamount = 330;
CString theDate = "'980606'";

Harish

Quote:

>I'm use VC++ with MFC's and this sentence build errors in the syntax.

>Is this SQL sentence wrong...?

>CString thecard = "342345";
>long  theamount = 330;
>CString theDate = "980606";

>CString strc = "insert into account(card,amount,date)
>values(thecard,theanount,thedate);

>pdb->ExecuteSQL(strc);

>Very Thanks!!!!!!
>josep



Fri, 24 Nov 2000 03:00:00 GMT  
 Database SQL INSERT

Hi Josep,

Actually what you need to do is something like this:

CString theCard = "342345";
long  theAmount = 330;
CString theDate = "980606";
CString strSql;

strSql.Format( _T("INSERT INTO Account (card,amount,date) VALUES
('%s',%d,'%s');"), theCard, theAmount, theDate );

pdb->ExecuteSQL( strSql );

HTH
--
===================
Frank Hickman
Computers Plus


===================



Mon, 27 Nov 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Using sql to insert data into Access database

2. Problem inserting data in SQL database

3. Inserting Muliple Records into SQL-SERVER Database

4. Insert data into Access database using sql

5. Inserting in to a SQL Server Database

6. SQL XML Bulk Insert

7. Inserting bytes into binary field in SQL 2K

8. Trying to insert data into SQL Server

9. SQL Server: Slow INSERT performance??

10. SQL question - DELETE, INSERT queries

11. Inserting a Delimited Text File into SQL Server

12. Sintax error in SQL INSERT INTO sentence

 

 
Powered by phpBB® Forum Software