阅读:1431回复:0
Visual Basic Example of an ODBC Dataset
Private Sub Command1_Click()
On Error GoTo MapXErr Dim ds As Dataset Dim parm as New ODBCQueryInfo ' You will need to include the ' Mapinfo ODBC Dataset engine library parm.SqlQuery = "select * from USA" ' if the ConnectString is left blank, the user will be ' prompted to find a driver and data source. This can include ' uid=, pwd=, and dlg= fields. ' Change the DBQ= line if MapX was installed in another ' location. parm.ConnectString = "ODBC;DRIVER={Microsoft Access Driver (*.mdb)};" & _ "DBQ=C:\Program Files\MapInfo\MapX 5.0\Data\MapStats.mdb;" ' Rather than providing connection information in the connect ' string, a named data source can be created in the ODBC Data ' Sources Control Panel and used here. parm.DataSource = "" ' Add the Dataset. Set ds = Map1.Datasets.Add(miDataSetODBC, parm, "ODBC Dataset") 'Create the default theme on the dataset ds.Themes.Add Exit Sub MapXErr: MsgBox "Error #" & Err.Number & ": " & Err.Description End Sub |
|
|