'Connect to the SQL database
Private sub bindsqldata ()
Dim cn as new ADODB. Connection
Dim RS as new ADODB. recordset
Rs. cursorlocation = aduseclient
'Strconn = "provider = Microsoft. Jet. oledb.4.0; Data Source =" & App. Path & "\ test. mdb; persist Security info = false" 'connect to access
CN. Open "provider = sqloledb; user id = sa; Password = 5316593; Data Source = 192.168.1.200; database = Bengang 921; persist Security info = true" 'connect to SQL Server oledb
'Cn. Open "provider = msdasql.1; user id = sa; Password = 5316593; Data Source = 192.168.1.200; database = Bengang 921; persist Security info = true" 'connect to SQL Server ODBC
Rs. Open "select a. nodename as sbmc, * From configurationtree A, machine B where a. nodeid = B. nodeid", CN, 1, 1
Set datagrid1.datasource = rs
If Rs. EOF then
Rs. Close
CN. Close
End if
End sub
'Connect to Oracle
Private sub bindoracledata ()
Dim RS as new ADODB. recordset
Dim conn as new ADODB. Connection
Dim strconn as string
'Database connection string
'Connect to a database with a password and add jet oledb: Database Password = 'your password' to the connector'
'Use jet. oledb.3.5 to connect to the Access97 database. Use jet. oledb.4.0 for access2k and later databases.
'Strconn = "provider = Microsoft. Jet. oledb.4.0; Data Source =" & App. Path & "\ test. mdb; persist Security info = false"
Strconn = "provider = msdaora.1; Password = rzeam; user id = rzeam; Data Source = rzeam; persist Security info = true" 'oracle driver
'Use client data curs'
Conn. cursorlocation = aduseclient
'Open access connection
Conn. Open strconn
'If the recordset status is not closed, disable the recordset.
If Rs. State <> adstateclosed then Rs. Close
'Recordser open the table people
Rs. Open "select * From configurationtree A, mm_sbkp B where a. nodeid = (B. ID * 100 + 1)", Conn, adopenkeyset, adlockoptimistic
'Report the total amount of data and test whether data exists
'Msgbox Rs. recordcount
'Bind to DataGrid
Set datagrid1.datasource = rs
End sub