Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Private Sub cmdAddNew_Click()
rst.AddNew
rst.Update
End Sub
Private Sub cmdDelete_Click()
rst.Delete
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub cmdSorting_Click()
ADO.Recordset.Sort = "field1 ASC"
End Sub
Private Sub Combo1_Click()
If Trim(Combo1.Text) = "" Then
Exit Sub '没有选择列则退出Click事件
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\金-A边界条件\坝体参数.mdb;Persist Security Info=False"
rst.CursorLocation = adUseClient '设置客户端
rst.Open "select * from 孔洞参数 where 'field1=combo1.Text'", cnn, adOpenKeyset, adLockOptimistic
Set DataGrid1.DataSource = rst '把得到的结果显示到DataGrid1里
End If
End Sub
Private Sub Command1_Click(Index As Integer)
n = Index
Select Case n
Case 0
rst.MoveFirst
Case 1
rst.MovePrevious
If rst.BOF Then rst.MoveLast
Case 2
rst.MoveNext
If rst.EOF Then rst.MoveFirst
Case 3
rst.MoveLast
End Select
End Sub
Private Sub Form_Load()
s = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\金-A边界条件\坝体参数.mdb;Persist Security Info=False"
cnn.Open s
Set rst = New Recordset
rst.Open "孔洞参数", cnn, adOpenStatic, adLockOptimistic
For Each aa In Text1
Set aa.DataSource = rst
Next
Set DataGrid1.DataSource = rst
Combo1.AddItem 6
Combo1.AddItem 7
Combo1.AddItem 8
Combo1.AddItem 9
Combo1.AddItem 10
Combo1.AddItem 11
Combo1.AddItem 12
Combo1.AddItem 13
Combo1.AddItem 14
Combo1.AddItem 15
Combo1.AddItem 16
Combo1.AddItem 17
Combo1.AddItem 18
Combo1.AddItem 19
Combo1.AddItem 20
Combo1.Text = Combo1.List(0)
End Sub