C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old May 24th, 2005, 09:07 AM
wedsall wedsall is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 1 wedsall User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m 45 sec
Reputation Power: 0
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.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > OLE DB with SQL - Questions.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT