Dim db_conn AsNew Connection db_conn.ConnectionString = MdlTranslate.ConnectionString() Dim s_sql AsString Dim db_record AsNew ADODB.Recordset db_record.CursorLocation = adUseClient s_sql ="Select * from tLicenseRecord" If db_conn.State <>0Then db_conn.Close db_conn.Open db_record.Open s_sql, db_conn, adOpenDynamic, adLockOptimistic Set dgLicenseRecord.DataSource = db_record dgLicenseRecord.Columns("PKID").Caption ="記錄號" dgLicenseRecord.Columns("Type").Caption ="類型" dgLicenseRecord.Columns("Number").Caption ="點數" dgLicenseRecord.Columns("LicenseID").Caption ="序列號" dgLicenseRecord.Columns("ProductName").Caption ="軟件產品名稱" dgLicenseRecord.Columns("RemainNumber").Caption ="剩余點數" dgLicenseRecord.Columns("Time").Caption ="時間"
2 FlexGrid
PrivateSub FillGrid() OnErrorResumeNext Dim conn AsNew Connection Dim rs AsNew Recordset conn.ConnectionString = ConnectionString conn.Open rs.Source = m_strSQL ' "select * from tLicenseRecord " Set rs.ActiveConnection = conn rs.Open Set Me.dgLicenseRecord.DataSource = rs 'Set Me.DataGrid1.DataSource = rs If rs.State = adStateOpen Then rs.Close conn.Close Set rs =Nothing Set conn =Nothing End Sub