Click here to Skip to main content
15,913,854 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: convert CString to SQLCHAR* Pin
anna mathew22-Oct-08 23:17
anna mathew22-Oct-08 23:17 
GeneralRe: convert CString to SQLCHAR* Pin
Rajesh R Subramanian22-Oct-08 23:20
professionalRajesh R Subramanian22-Oct-08 23:20 
JokeRe: convert CString to SQLCHAR* Pin
CPallini22-Oct-08 23:46
mveCPallini22-Oct-08 23:46 
QuestionRe: convert CString to SQLCHAR* Pin
CPallini22-Oct-08 23:42
mveCPallini22-Oct-08 23:42 
AnswerRe: convert CString to SQLCHAR* Pin
KarstenK22-Oct-08 20:51
mveKarstenK22-Oct-08 20:51 
QuestionRe: convert CString to SQLCHAR* [modified] Pin
CPallini22-Oct-08 21:44
mveCPallini22-Oct-08 21:44 
AnswerRe: convert CString to SQLCHAR* Pin
anna mathew23-Oct-08 0:46
anna mathew23-Oct-08 0:46 
AnswerRe: convert CString to SQLCHAR* Pin
anna mathew22-Oct-08 23:30
anna mathew22-Oct-08 23:30 
Ive Edited My Code To:


void CInsert::OnBnClickedOk()
{
OnOK();
SQLRETURN sr;
SQLHSTMT hstmt;
SQLCHAR SQL[] ="INSERT INTO Contacts (FirstName, LastName, Address) VALUES('?','?','?')";

//Take the values entered in edit box to CEdit *
m_First.GetWindowText(Firstname);
m_Last.GetWindowText(Lastname);
m_Add.GetWindowText(Address);

SQLINTEGER FirstNameLength = SQL_NTS;
SQLINTEGER AddressLength = SQL_NTS;
SQLINTEGER LastNameLength = SQL_NTS;
SQLINTEGER FullLength = SQL_NTS;

// Allocate a new statement handle
sr = SQLAllocHandle(SQL_HANDLE_STMT, hDbConn, &hstmt);

// Prepare statement
if(sr != SQL_SUCCESS && sr != SQL_SUCCESS_WITH_INFO)
displayODBCError(sr,"Error in SQLAllocHandle in OnViewTestpreparedinsert");
sr = SQLPrepare(hstmt, SQL, SQL_NTS);
if(sr != SQL_SUCCESS && sr != SQL_SUCCESS_WITH_INFO)
displayODBCError(sr,"Error in SQLPrepare in OnViewTestpreparedinsert");

// Bind Parameters
sr = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 10, 0,
&Firstname, sizeof(Firstname), &FirstNameLength);
if(sr != SQL_SUCCESS && sr != SQL_SUCCESS_WITH_INFO)
displayODBCError(sr,"Error in Binding 2 in OnViewTestpreparedinsert");
sr = SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT,
SQL_C_CHAR, SQL_CHAR, 10, 0, &Lastname, sizeof(Lastname), &LastNameLength);
if(sr != SQL_SUCCESS && sr != SQL_SUCCESS_WITH_INFO)
displayODBCError(sr,"Error in Binding 3 in OnViewTestpreparedinsert");
sr = SQLBindParameter(hstmt, 3, SQL_PARAM_INPUT,SQL_C_CHAR, SQL_CHAR, 10, 0,
&Address, sizeof(Address), &AddressLength);
if(sr != SQL_SUCCESS && sr != SQL_SUCCESS_WITH_INFO)
displayODBCError(sr,"Error in Binding 3 in OnViewTestpreparedinsert");

// Execute statement with parameters
sr = SQLExecute(hstmt);
if(sr != SQL_SUCCESS && sr != SQL_SUCCESS_WITH_INFO)
displayODBCError(sr,"Error in SQLExecute in OnViewTestpreparedinsert");

SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
}



...................................................................

Ive Also Tried ...........

void CInsert::OnBnClickedOk()
{
// TODO: Add your control notification handler code here
OnOK();
SQLRETURN sr;

//Take the values entered in edit box to CEdit
m_First.GetWindowText(Firstname);
m_Last.GetWindowText(Lastname);
m_Add.GetWindowText(Address);
CString FullName = "INSERT INTO Contacts (FirstName, LastName, Address) VALUES ('" +Firstname+ "', '" +Lastname+"','" + Address+"'))";
executeSQL((SQLCHAR *) (LPCTSTR)FullName);
}






................................
Both I get the Same ERROR::::::

error C2594: 'static_cast' : ambiguous conversions from
'void (__thiscall CInsert::* )(void)' to 'AFX_PMSG'


........................Y Is It?
QuestionRe: convert CString to SQLCHAR* Pin
CPallini22-Oct-08 23:56
mveCPallini22-Oct-08 23:56 
AnswerRe: convert CString to SQLCHAR* Pin
anna mathew23-Oct-08 0:11
anna mathew23-Oct-08 0:11 
GeneralRe: convert CString to SQLCHAR* Pin
anna mathew23-Oct-08 0:15
anna mathew23-Oct-08 0:15 
GeneralRe: convert CString to SQLCHAR* Pin
CPallini23-Oct-08 0:49
mveCPallini23-Oct-08 0:49 
GeneralRe: convert CString to SQLCHAR* Pin
anna mathew23-Oct-08 19:24
anna mathew23-Oct-08 19:24 
GeneralRe: convert CString to SQLCHAR* Pin
CPallini23-Oct-08 21:34
mveCPallini23-Oct-08 21:34 
QuestionPicture Control Pin
MsmVc22-Oct-08 18:50
MsmVc22-Oct-08 18:50 
QuestionSendMessage seemingly doing nothing at certain point in recursion Pin
kamrann22-Oct-08 15:33
kamrann22-Oct-08 15:33 
QuestionHow can I display Dlg Message Box? Pin
sabdalla8022-Oct-08 9:53
sabdalla8022-Oct-08 9:53 
AnswerRe: How can I display Dlg Message Box? Pin
David Crow22-Oct-08 9:58
David Crow22-Oct-08 9:58 
GeneralRe: How can I display Dlg Message Box? Pin
sabdalla8022-Oct-08 10:09
sabdalla8022-Oct-08 10:09 
GeneralRe: How can I display Dlg Message Box? Pin
sabdalla8022-Oct-08 10:22
sabdalla8022-Oct-08 10:22 
QuestionRe: How can I display Dlg Message Box? Pin
David Crow22-Oct-08 10:37
David Crow22-Oct-08 10:37 
AnswerRe: How can I display Dlg Message Box? Pin
sabdalla8022-Oct-08 10:43
sabdalla8022-Oct-08 10:43 
QuestionRe: How can I display Dlg Message Box? Pin
David Crow22-Oct-08 10:47
David Crow22-Oct-08 10:47 
QuestionGetting NULL value from 'Win32_LogonSession' through WMI [modified] Pin
Supriya Tonape22-Oct-08 9:40
Supriya Tonape22-Oct-08 9:40 
QuestionRe: Getting NULL value from 'Win32_LogonSession' through WMI Pin
David Crow22-Oct-08 9:57
David Crow22-Oct-08 9:57 

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.