How to Set VB Data Control to External ODBC Database DynasetID: Q109800
|
The following sample code fragment sets a data control (Data1) to a
Dynaset based upon an external ODBC database:
' Set DatabaseName property to a valid Data Source Name (DSN) that is
' registered in the ODBC.INI file in your Windows directory:
Data1.DatabaseName = "datasourcename"
Data1.Connect = "odbc;uid=user;pwd=password;database=pubs"
Data1.RecordSource = "tablename"
' Or you can set the Data1.RecordSource property to an SQL query:
' Data1.RecordSource = "select * from tablename where ..."
Data1.Refresh ' Must update the data control with new Dynaset.
Dim ds as Dynaset
...
Set Data1.Recordset = ds 'This statement is not supported.
Set ds = Data1.Recordset 'This statement is supported.
Before you can edit an external ODBC table, the table must contain a unique
index. If you get the following error message, you might not have a unique
index on the table:
Can't perform operation; it is illegal.
Additional query words: 3.00
Keywords :
Version :
Platform :
Issue type :
Last Reviewed: June 18, 1999