主要源代码如下:
公共模块
Public Cn As New ADODB.Connection ''连接数据库
Public UserID As String ''用户名称
Public ItemName As String ''项目名称
Public strTableName As String ''表名
Public UserType As String
Public SelData(10)
Const DayLastFine = 0.5 '定义超期每天费用0.5元
Sub Init()
ItemName = "图书管理系统"
Call ConnectData
End Sub
Sub ConnectData()
If Cn.State Then Cn.Close
Cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\database.mdb;Persist Security Info=False"
Cn.Open
End Sub
Sub LoadGrid(mfg As MSHFlexGrid, rstSql As String)
Dim rst As New ADODB.Recordset
rst.Open rstSql, Cn, adOpenStatic, adLockReadOnly
With mfg
.Clear
.Rows = 2
.Cols = rst.Fields.Count
For i = 0 To rst.Fields.Count - 1
.TextMatrix(0, i) = Trim(rst(i).Name)
.ColWidth(i) = (.Width - 500) / .Cols
Next i
While Not rst.EOF
For i = 0 To rst.Fields.Count - 1
If Not IsNull(rst(i)) Then .TextMatrix(.Rows - 1, i) = Trim(rst(i))
Next i
.Rows = .Rows + 1
rst.MoveNext
Wend
End With
End Sub
公共模块
Public Cn As New ADODB.Connection ''连接数据库
Public UserID As String ''用户名称
Public ItemName As String ''项目名称
Public strTableName As String ''表名
Public UserType As String
Public SelData(10)
Const DayLastFine = 0.5 '定义超期每天费用0.5元
Sub Init()
ItemName = "图书管理系统"
Call ConnectData
End Sub
Sub ConnectData()
If Cn.State Then Cn.Close
Cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\database.mdb;Persist Security Info=False"
Cn.Open
End Sub
Sub LoadGrid(mfg As MSHFlexGrid, rstSql As String)
Dim rst As New ADODB.Recordset
rst.Open rstSql, Cn, adOpenStatic, adLockReadOnly
With mfg
.Clear
.Rows = 2
.Cols = rst.Fields.Count
For i = 0 To rst.Fields.Count - 1
.TextMatrix(0, i) = Trim(rst(i).Name)
.ColWidth(i) = (.Width - 500) / .Cols
Next i
While Not rst.EOF
For i = 0 To rst.Fields.Count - 1
If Not IsNull(rst(i)) Then .TextMatrix(.Rows - 1, i) = Trim(rst(i))
Next i
.Rows = .Rows + 1
rst.MoveNext
Wend
End With
End Sub