?? module1.bas
字號:
Attribute VB_Name = "Module1"
Public Conn As New ADODB.Connection
Public Rs As New ADODB.Recordset
Public Cmd As New ADODB.Command
'數據查詢函數,只需要給出相應的SQL語句,返回一個與函數同名的記錄集對象
Public Function ExecuteSQL(ByVal SQL As String) As ADODB.Recordset
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Set cnn = New ADODB.Connection
Dim stokens() As String
stokens = Split(SQL)
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\學生信息管理.mdb;Persist Security Info=False"
If InStr("insert,delete,update", UCase$(stokens(0))) Then
cnn.Execute SQL
Else
Set rst = New ADODB.Recordset
rst.Open Trim$(SQL), cnn, adOpenKeyset, adLockOptimistic
End If
Set ExecuteSQL = rst
End Function
'用來在dgrid網格中顯示記錄集Rs中的內容
Public Sub Showdata(Rs As ADODB.Recordset, dgrid As MSHFlexGrid)
Dim Rownum As Integer
Rownum = 1
dgrid.Rows = Rownum
dgrid.Cols = Rs.Fields.Count
For j = 0 To Rs.Fields.Count - 1
dgrid.TextMatrix(0, j) = Rs.Fields(j).Name
Next j
Do While Not Rs.EOF
Rownum = Rownum + 1
dgrid.Rows = Rownum
For j = 0 To Rs.Fields.Count - 1
If Not IsNull(Rs.Fields(j).Value) Then
dgrid.TextMatrix(Rownum - 1, j) = Rs.Fields(j).Value
End If
Next j
Rs.MoveNext
Loop
End Sub
' 圖片保存的函數
'Sub Savepicturetoado(Rs As ADODB.Recordset, ByVal Filename As String)
'Dim Length As Long, f As Integer
'Length = FileLen(Filename)
' ReDim barray(Length + 12) As Byte, barray2(Length) As Byte
'barray(0) = &H6C: barray(1) = &H74
'rtlmovememory barray(4), Length, 4
' f = FreeFile
' Open Filename For Binary As #f
'Get #f, , barray2
'Close #1
'rtlmovememory barray(8), barray2(0), Length
'Rs("照片").AppendChunk barray
'End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -