Click here to Skip to main content
16,021,041 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Does Postmessage/SendMessage require a Message Map entries Pin
ForNow22-May-09 10:50
ForNow22-May-09 10:50 
GeneralRe: Does Postmessage/SendMessage require a Message Map entries Pin
«_Superman_»22-May-09 16:21
professional«_Superman_»22-May-09 16:21 
GeneralRe: Does Postmessage/SendMessage require a Message Map entries Pin
ForNow23-May-09 15:33
ForNow23-May-09 15:33 
QuestionGPS & GoogleMap matching Pin
yunpil22-May-09 5:17
yunpil22-May-09 5:17 
AnswerRe: GPS & GoogleMap matching Pin
Stuart Dootson22-May-09 6:33
professionalStuart Dootson22-May-09 6:33 
RantRe: GPS & GoogleMap matching Pin
Rajesh R Subramanian23-May-09 0:39
professionalRajesh R Subramanian23-May-09 0:39 
QuestionOutlook email(.Msg ) file problem in vista explorer.... Pin
onlyjaypatel22-May-09 3:33
onlyjaypatel22-May-09 3:33 
QuestionCommand object execute parameters [modified] Pin
vital_parsley200022-May-09 2:56
vital_parsley200022-May-09 2:56 
void CSimpdbView::OnRecordsInsert()
{
CSimpdbDoc* pDoc = GetDocument();
_CommandPtr pCmd = NULL;
pCmd.CreateInstance(__uuidof(Command));

//Disables window once data entering is finished.

CEdit* ePtr = (CEdit*)GetDlgItem(IDC_ISBN);
ePtr->EnableWindow(FALSE);
ePtr = (CEdit*)GetDlgItem(IDC_NAME);
ePtr->EnableWindow(FALSE);
ePtr = (CEdit*)GetDlgItem(IDC_PAGES);
ePtr->EnableWindow(FALSE);
ePtr = (CEdit*)GetDlgItem(IDC_EDITION);
ePtr->EnableWindow(FALSE);
ePtr = (CEdit*)GetDlgItem(IDC_AUTHOR);
ePtr->EnableWindow(FALSE);

//Saves data from edit box in respective variables.

CString strIsbn,strName,strPages,strEdition,strAuthor;
ePtr = (CEdit*)GetDlgItem(IDC_ISBN);
ePtr->GetWindowText(strIsbn);
ePtr = (CEdit*)GetDlgItem(IDC_NAME);
ePtr->GetWindowText(strName);
ePtr = (CEdit*)GetDlgItem(IDC_PAGES);
ePtr->GetWindowText(strPages);
ePtr = (CEdit*)GetDlgItem(IDC_EDITION);
ePtr->GetWindowText(strEdition);
ePtr = (CEdit*)GetDlgItem(IDC_AUTHOR);
ePtr->GetWindowText(strAuthor);

//Database code.

_bstr_t sqlQuery("Insert into lib_book_details values(?,?,?,?,?)");
pCmd->ActiveConnection = pDoc->m_pConnection;
pCmd->CommandText=sqlQuery;

try
{
pCmd->CreateParameter("strIsbn",adVarChar,adParamInput,sizeof(char),vtMissing);
pCmd->CreateParameter("strName",adVarChar,adParamInput,sizeof(char),vtMissing);
pCmd->CreateParameter("strPages",adVarChar,adParamInput,sizeof(char),vtMissing);
pCmd->CreateParameter("strEdition",adVarChar,adParamInput,sizeof(char),vtMissing);
pCmd->CreateParameter("strAuthor",adVarChar,adParamInput,sizeof(char),vtMissing);

pCmd->Parameters->Append((_variant_t)strIsbn); //GOES INTO THE CATCH BLOCK FROM HERE.
pCmd->Parameters->Append((_variant_t)strName);
pCmd->Parameters->Append((_variant_t)strPages);
pCmd->Parameters->Append((_variant_t)strEdition);
pCmd->Parameters->Append((_variant_t)strAuthor);
pCmd->Execute(NULL,NULL,adCmdText);


MessageBox("Record Inserted.",NULL,MB_OK);

}

catch(_com_error &e)
{
TRACE( "Error:%08lx.\n", e.Error());
TRACE( "ErrorMessage:%s.\n", e.ErrorMessage());
TRACE( "Source:%s.\n", (LPCTSTR) _bstr_t(e.Source()));
TRACE( "Description:%s.\n", (LPCTSTR)_bstr_t(e.Description()));
}
catch(...)
{
TRACE("**********Unhandled Exception*********");
}
}

I m trying to execute the above code .But the code above does not insert the data into database.What is wrong with the code.It executes the catch block from the statetment ::

pCmd->Parameters->Append((_variant_t)strIsbn);

I would appreciate the help .I have used this website http://support.microsoft.com/default.aspx/kb/181734[^]"> as reference.

modified on Friday, May 22, 2009 9:06 AM

QuestionRe: Command object execute parameters Pin
CPallini22-May-09 3:08
mveCPallini22-May-09 3:08 
AnswerRe: Command object execute parameters Pin
vital_parsley200022-May-09 4:01
vital_parsley200022-May-09 4:01 
GeneralRe: Command object execute parameters Pin
Stuart Dootson22-May-09 4:52
professionalStuart Dootson22-May-09 4:52 
GeneralRe: Command object execute parameters Pin
vital_parsley200022-May-09 5:13
vital_parsley200022-May-09 5:13 
GeneralRe: Command object execute parameters Pin
Stuart Dootson22-May-09 6:02
professionalStuart Dootson22-May-09 6:02 
GeneralRe: Command object execute parameters Pin
Stuart Dootson22-May-09 6:32
professionalStuart Dootson22-May-09 6:32 
GeneralRe: Command object execute parameters Pin
vital_parsley200022-May-09 19:01
vital_parsley200022-May-09 19:01 
AnswerRe: Command object execute parameters Pin
CPallini22-May-09 6:05
mveCPallini22-May-09 6:05 
GeneralRe: Command object execute parameters Pin
vital_parsley200022-May-09 6:32
vital_parsley200022-May-09 6:32 
GeneralRe: Command object execute parameters Pin
CPallini22-May-09 8:38
mveCPallini22-May-09 8:38 
GeneralRe: Command object execute parameters Pin
vital_parsley200022-May-09 19:34
vital_parsley200022-May-09 19:34 
GeneralRe: Command object execute parameters Pin
Stuart Dootson22-May-09 22:16
professionalStuart Dootson22-May-09 22:16 
GeneralRe: Command object execute parameters Pin
vital_parsley200023-May-09 0:38
vital_parsley200023-May-09 0:38 
QuestionDebug Assertion Failed Pin
Davitor22-May-09 2:29
Davitor22-May-09 2:29 
AnswerRe: Debug Assertion Failed Pin
sujeet22-May-09 2:37
sujeet22-May-09 2:37 
GeneralRe: Debug Assertion Failed Pin
Davitor22-May-09 2:48
Davitor22-May-09 2:48 
QuestionQuery About SDI Application Pin
Saleem Anwar22-May-09 1:08
Saleem Anwar22-May-09 1:08 

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.