| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
OLE DB with SQL - Questions.
I'm new with C++ but not to object oriented programming. I used the MFC tutorial to create a DB connection to a ms sql server, and put the data into a listbox.
I'm having trouble pushing data back into the DB. Could someone please give me a better understanding on how the oledb sql connections work, and how to insert into the db? the following code doesn't give me an error, but doesn't work either. using the pubs test table.. HRESULT hr = S_OK; CMyProject2Set &dbset = GetDocument()->m_MyProject2Set; [db_command(name="cmd", source_name="dbset", hresult=hr) { INSERT INTO AUTHORS (au_lname, au_fname, au_id, contract) VALUES(test, test1, 999-99-9999, 1) }]; ------ Here is the snippet given with the walkthrough, and it does work. HRESULT hr = S_OK; TCHAR szAuthor[80]; CMyProject2Set &dbset = GetDocument()->m_MyProject2Set; [db_command(name="cmda", source_name="dbset", hresult=hr) { SELECT au_lname ([bindto]szAuthor) FROM AUTHORS ORDER BY au_lname ASC }]; while(cmda.MoveNext() == S_OK) m_DataList.InsertString(-1,szAuthor); ----- My db_source, db_table, and the class CMyProject2Set are located in MyProjectSet2.h. Either my insert statement is wrong with c++, or i need to modify the .h. Thanks in advance for shedding some light on my situation! Hopefully it's something simple. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > OLE DB with SQL - Questions. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|