Click here to Skip to main content
15,881,882 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Why this is not failing in VC6 Pin
Sarath C30-May-06 23:57
Sarath C30-May-06 23:57 
GeneralRe: Why this is not failing in VC6 Pin
NiceNaidu31-May-06 0:01
NiceNaidu31-May-06 0:01 
AnswerRe: Why this is not failing in VC6 Pin
Sarath C31-May-06 0:02
Sarath C31-May-06 0:02 
AnswerRe: Why this is not failing in VC6 Pin
Michael Dunn31-May-06 2:06
sitebuilderMichael Dunn31-May-06 2:06 
QuestionWhy "new" operator is "thread_safe" ? Pin
Ajax9530-May-06 23:17
Ajax9530-May-06 23:17 
AnswerRe: Why "new" operator is "thread_safe" ? Pin
BadKarma30-May-06 23:40
BadKarma30-May-06 23:40 
AnswerRe: Why "new" operator is "thread_safe" ? Pin
Nemanja Trifunovic31-May-06 1:28
Nemanja Trifunovic31-May-06 1:28 
QuestionC++ and ADO problem Pin
antonaras30-May-06 22:58
antonaras30-May-06 22:58 
Hi again

I hava a problem again executing an sql statment(INSERT) in my program
can anyone help me find whats wrong?

hr = S_OK;<br />
	CoInitialize(NULL);<br />
<br />
	try<br />
	{<br />
		_ConnectionPtr m_pConn;<br />
		HRESULT hr =m_pConn.CreateInstance(__uuidof(Connection));<br />
		if (FAILED( hr ))<br />
			cout<<"Can't create an intance of ADO.Connection"<<endl;<br />
 <br />
		if (FAILED( m_pConn->Open(_bstr_t("Provider=Microsoft.Jet.OLEDB.4.0;Data Source =ADOTestDB.MDB"),<br />
			_bstr_t( "" ),<br />
			_bstr_t( "" ), <br />
			adModeUnknown )))<br />
			<br />
			cout<<"Can't open datasource"<<endl;<br />
<br />
<br />
<br />
<br />
		_bstr_t strDepId="12";<br />
		_bstr_t strName="Art";<br />
		_bstr_t strOfficeNo="256";<br />
		_bstr_t strTel="22491303";<br />
		_bstr_t strDepHead="Dr.Antonis Marcou";<br />
<br />
		_bstr_t strSQL("Insert into Dept(DeptID,Name,OfficeNo,Phone,DeptHead) Values(");<br />
		strSQL += strDepId + strName + strOfficeNo + strTel + strDepHead ;<br />
<br />
		printf("%s\n",(LPCSTR)strSQL);//The program works up to here then   it gives me an error:0x<br />
	<br />
		m_pConn->Execute(strSQL,NULL,adExecuteNoRecords);<br />
<br />
		printf("Data Added Successfully\n",(LPCSTR)strSQL);<br />
<br />
		m_pConn->Close();<br />
		<br />
	}catch( _com_error &ce )<br />
	{<br />
		printf("Error:%s\n",ce.Description);<br />
<br />
	}<br />
<br />
	CoUninitialize();



I wrote the program almost the same way as the sample code but still is not working

the fiels in the db are
DeptID: number
Name: Text
OfficeNo: number
Phone: text
DeptHead: text

Any ideas?
thanks a lot for all the help you gave me so far
AnswerRe: C++ and ADO problem Pin
NiceNaidu30-May-06 23:05
NiceNaidu30-May-06 23:05 
GeneralRe: C++ and ADO problem Pin
antonaras30-May-06 23:09
antonaras30-May-06 23:09 
GeneralRe: C++ and ADO problem Pin
antonaras31-May-06 0:04
antonaras31-May-06 0:04 
GeneralRe: C++ and ADO problem Pin
NiceNaidu31-May-06 0:12
NiceNaidu31-May-06 0:12 
AnswerRe: C++ and ADO problem Pin
echozeng31-May-06 5:24
echozeng31-May-06 5:24 
QuestionSet Windows login authentication option programmatically Pin
QuickDeveloper30-May-06 22:20
QuickDeveloper30-May-06 22:20 
AnswerRe: Set Windows login authentication option programmatically Pin
Ștefan-Mihai MOGA30-May-06 22:43
professionalȘtefan-Mihai MOGA30-May-06 22:43 
AnswerRe: Set Windows login authentication option programmatically [modified] Pin
_anil_30-May-06 22:44
_anil_30-May-06 22:44 
GeneralRe: Set Windows login authentication option programmatically [modified] Pin
narayanagvs30-May-06 23:30
narayanagvs30-May-06 23:30 
GeneralRe: Set Windows login authentication option programmatically [modified] Pin
_anil_30-May-06 23:44
_anil_30-May-06 23:44 
GeneralRe: Set Windows login authentication option programmatically [modified] Pin
narayanagvs31-May-06 0:26
narayanagvs31-May-06 0:26 
GeneralRe: Set Windows login authentication option programmatically [modified] Pin
_anil_31-May-06 1:06
_anil_31-May-06 1:06 
GeneralRe: Set Windows login authentication option programmatically [modified] Pin
narayanagvs31-May-06 2:34
narayanagvs31-May-06 2:34 
QuestionTime Pin
Try30-May-06 22:11
Try30-May-06 22:11 
AnswerRe: Time Pin
Nibu babu thomas30-May-06 22:19
Nibu babu thomas30-May-06 22:19 
AnswerRe: Time Pin
_AnsHUMAN_ 30-May-06 22:47
_AnsHUMAN_ 30-May-06 22:47 
AnswerRe: Time [modified] Pin
Arsalan Malik30-May-06 23:51
Arsalan Malik30-May-06 23:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.