Click to See Complete Forum and Search --> : ADO Control wrapper class


Valer BOCAN
April 23rd, 1999, 12:29 PM
I am trying to connect an ADO control to a table at runtime. ClassWizard generated a wrapper class and I tried the following:


m_Adodc.SetConnectionString((LPCSTR)"ODBC;DSN=MQIS");
m_Adodc.SetUserName((LPCSTR)"vbocan");
m_Adodc.SetPassword((LPCSTR)"");
m_Adodc.SetCommandType(2); //Table
m_Adodc.SetRecordSource((LPCSTR)"_Prefix");




When running the program, the ADO control is disabled and the datagrid linked to it shows nothing. If I do the same operations at design time (setting properties from ADO's configuration panels) everything works ok.
Could someone tell me what's going on?
I am new to DB-programming in VC++, C++ Builder is so much easier...

Hurol Aslan
May 3rd, 1999, 02:16 PM
Hello,

My first answer would be to look at ADO samples and follow their examples.
i.e., create and use database and connection objects rather than accessing them via the ADO data control.

But if you would like to use the data control, I think you also need to call the GetDSCCursor() method of the data control. This method is inherited from the CWnd class, so it will not appear in the header file of the data control wrapper class. After that, you also need to use the Refresh() method to make sure that the bound grid will display the data. Check the mdibind sample of VC++; it includes code similar to yours.