Hello,
I need to write a C++ command line program that Inserts, Deletes, Updates
and Selects records from a Microsoft SQL Server Database. I'd really like
to simply open a recrodset like this:
connectStr=_T("ODBC;Provider=MSDASQL;Driver={SQL
Server};Server=192.168.1.2;Database=EOS;Uid=sa;Pwd=sa;");
db.Open(NULL,FALSE,FALSE,connectStr,TRUE);
CRecordset rs(&db);
SQLstring="SELECT * FROM Subscribers WHERE LocationCode='" + buildingStr +
"-" + apartmentStr + "';";
rs.Open(CRecordset::forwardOnly,_T(SQLstring));
The above works great and returns the records. I can movefirst, movenext,
blah, blah. But, I need to be able to Insert, Update and delete like this
too:
CString SQLinsert="INSERT INTO
Changes(LocationCode,Gr
p,Tap,TapType,ChangeDate)VALUES('" + buildingStr +
"-" + apartmentStr + "','" + groupStr + "','" + tapStr + "','" + taptypeStr
+ "','11-10-02');";
rs.Open(CRecordset::dynaset,_T(SQLinsert));
I get an unhandled exception 0xE067363. I know this is a lot to
swallow, but can someone give me some tips or maybe suggest a better way to
do it. I'm very fluent in both C++ and SQL, I'm just stuck. You now how it
is.
Thanks alot,
Eric Kowalewski