Click here to Skip to main content
15,909,829 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
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 
Ive Reffered InformIT C++ 6 Unleashed to do database programming......

Ive not used CDatabase......

In My Program ...Initially Thr Is A Menu Bar With Options...
Connect...Insert....Delete...and View...

on Clicking Connect I get Connected to Database...
all the other options can be pressed only after this...

initially my code was working.....
in Insert,Delete functions i had given only one statement...
that is :

executeSQL((SQLCHAR *) "INSERT INTO Contacts (Firstname,Lastname,Address) values ('MIKE', 'C', 'India'");


//in delete
executeSQL((SQLCHAR *) "DELETE FROM Contacts WHERE FirstName ='MIKE'");



//code executeSQL
void CMsQueryView::executeSQL (SQLCHAR *SQL)
{
SQLRETURN sr; //Return code for your ODBC calls
SQLHSTMT hstmt;
// Allocate new Statement Handle based on previous connection
sr = SQLAllocHandle(SQL_HANDLE_STMT, hDbConn, &hstmt);
if(sr != SQL_SUCCESS && sr != SQL_SUCCESS_WITH_INFO)
{
char message[200];
sprintf (message, "Error Allocating Handle: %d\n", sr);
AfxMessageBox(message);
}
sr = SQLExecDirect(hstmt, SQL, SQL_NTS);
if(sr != SQL_SUCCESS && sr != SQL_SUCCESS_WITH_INFO)
{
char message[200];
sprintf (message, "Error in SQLExecDirect. SQL was:\n\n%s\n\n", SQL);
displayODBCError(sr, message);
}
SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
}

//odbc error function

void CMsQueryView::displayODBCError (SQLRETURN sr,char *inMessage)
{
if(sr != SQL_SUCCESS && sr != SQL_SUCCESS_WITH_INFO)
{
SQLCHAR SqlState[6];
SQLINTEGER NativeError;
SQLCHAR ErrMsg[SQL_MAX_MESSAGE_LENGTH];
int i = 1;
char message[512];
strcpy (message, "");
if (inMessage)
{
strcpy(message, inMessage);
strcat(message, " — ");
}
sprintf(message, "%sError in SQLConnect(): %d.",
message, sr);
AfxMessageBox(message);
while(SQLGetDiagRec(SQL_HANDLE_DBC, hDbConn, i,SqlState, &NativeError,
ErrMsg, sizeof(ErrMsg), NULL)!= SQL_NO_DATA)
{
sprintf(message,"Diag: %d, SQLSTATE: %s NativeError: %d ErrMsg: %s",
i++, SqlState, NativeError, ErrMsg);
AfxMessageBox(message);
}
}
}


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

then it worked.....
now im tryin to get the values from user and then tryin to write it to database.....
thats y i made the changes to BnClickedOk()
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 
AnswerRe: Getting NULL value from 'Win32_LogonSession' through WMI Pin
Supriya Tonape22-Oct-08 10:24
Supriya Tonape22-Oct-08 10:24 
QuestionRe: Getting NULL value from 'Win32_LogonSession' through WMI Pin
David Crow22-Oct-08 10:35
David Crow22-Oct-08 10:35 

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.