How to use GetDlgItemText with Win32 ADO Recordsets ?
With the assistance of your site and the msdn site I have finally got to grips with the basics of the ADOX commands and then realised this is only useful for accessing and creating the schema. Sigh, so had to root around the ADO stuff that I haven't used in literally ages to access the data. But finally did it. Only took all weekend to figure it out. Haha. Using Visual C++ 6 Win32 code in case you were wondering.
So now I can create databases and tables (Access MDBs by the way) and using hard coded values add and retrieve records. So now I want to utilise dialog boxes to retrieve user input that will add or amend records in the recordsets in question. One problem though. I can convert from the variable type GetDlgItemText seems to insist on (TCHAR varname[25]) to what ADO uses to utilise strings (_bstr_t).
Now the ADO is AOK article by Bob Place was handy in that it helped me pinpoint some earlier bugs in my program but now I need to find out how to get the EDIT box values into my recordset fields and vice versa.
Variables to pass edit box contents to
TCHAR col1[25];
TCHAR col2[15];
TCHAR col3[15];
>> Note: tried char* LPTSTR etc so as to get rid of 25/15/15 values but no data is retrieved from the edit box for some reason.
Code exectuted when the OK button is pressed.
GetDlgItemText(hDlg,IDC_EDIT1,col1,25);
GetDlgItemText(hDlg,IDC_EDIT2,col2,15);
GetDlgItemText(hDlg,IDC_EDIT3,col3,15);
Code to retrieve data to edit.
Open MDB File, Open a Recordset with a SELECT statement.
// We now have a record available to retrieve data from and place in dialog vars
col1 = (char*)(_bstr_t(dbd.m_pRecordset->GetCollect("Col1")));
col2 = _bstr_t(dbd.m_pRecordset->GetCollect("Col2"));
col3 = _bstr_t(dbd.m_pRecordset->GetCollect("Col3"));
// This reports inability to convert char* to char or _bstr_t to char.
DisplayDialog and Initialise with retrieved data
Close Recordset and MDB File
I am almost at hair pulling stage after spending ages trying to figure out why this isn't working. What do I need to do to mesh the Dialog string values to the ADO string values in Win32 that is?
I heard that std::string is the Win32 alternative to CString but my app had a problem with the std:: part so will look into that when I next have a chance, which by the current time will be in about 20 hrs time what with sleep and work.
Thanks for any light you can shed on what no doubt will be so simple a solution I overlooked it. Haha
Xrystal

