Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

i'm using Database Object (CDatabas 1

Status
Not open for further replies.

jl3574

Programmer
Joined
Jun 5, 2003
Messages
76
Location
CA
i'm using Database Object (CDatabase) in Visual C++, to connect to ms sql server..

sprintf(sql, "insert into TABLE_STYLES(STYLE_NAME) values('%s')",temp1);
theDb->ExecuteSQL(sql);

i use an sample statment like this to put data info the database.

my question is simple
how do i extract a value from the sql database and put it in a variable so i can use it in my program?
 
I didn't do it ever, but I found this:
You need to use CRecordSet because ExecuteSQL return no rows.
You can find many examples. Here is one:
//open database
CString strSQL;
m_cbTable.GetLBText(nCurSel, strSQL);
strSQL = _T("SELECT * FROM ") + strSQL; // you can set any query

// Open the recordset
rs.Open(CRecordset::snapshot, strSQL, CRecordset::readOnly | CRecordset::useMultiRowFetch);

From the recordset you can get your answer, look for examples.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top