📄 form5.frm
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form Form5
Caption = "Form5"
ClientHeight = 7125
ClientLeft = 60
ClientTop = 450
ClientWidth = 9690
LinkTopic = "Form5"
ScaleHeight = 7125
ScaleWidth = 9690
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command2
Caption = "退出"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 855
Left = 7800
TabIndex = 2
Top = 3360
Width = 1695
End
Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1
Height = 7095
Left = 0
TabIndex = 1
Top = 0
Width = 7455
_ExtentX = 13150
_ExtentY = 12515
_Version = 393216
End
Begin VB.CommandButton Command1
Caption = "返回"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 855
Left = 7800
TabIndex = 0
Top = 4200
Width = 1695
End
End
Attribute VB_Name = "Form5"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Form3.Show
Unload Form5
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
Dim cnn1 As ADODB.Connection '连接
Dim mycommand As ADODB.Command '命令
Dim rstByQuery As ADODB.Recordset '结果集
Dim strCnn As String '连接字符串
Set cnn1 = New ADODB.Connection '生成一个连接
strCnn = "FileDSN=DBtest.dsn;UID=sa;PWD="
'没有系统数据源使用连接字符串
'strCnn = "DSN=mydsn;UID=sa;PWD=;"
'DATABASE=pubs;Driver={SQL Server};SERVER=gzl_pc" '
'如果系统数据源MYDSN指向PUBS数据库,也可以这样用
cnn1.Open strCnn, , , 0 '打开连接
sql = "exec sumcalculater4"
cnn1.Execute (sql)
Dim i As Integer
Dim j As Integer
Set parm = New ADODB.Parameter
Set mycommand = New ADODB.Command
' parm_jobid.Name = "name1" 'this line can be ommited
parm.Type = adChar '参数类型
parm.Size = 10 '参数长度
parm.Direction = adParamInput '参数方向,输入或输出
mycommand.Parameters.Append parm '加入参数
mycommand.ActiveConnection = cnn1 '指定该command 的当前活动连接
mycommand.CommandText = " select c.*,r.rkshuliang from ckudanju c ,rkudanju r"
mycommand.CommandType = adCmdText '表明command 类型
Set rstByQuery = New ADODB.Recordset
Set rstByQuery = mycommand.Execute()
i = 0
Do While Not rstByQuery.EOF
i = i + 1 ' i 中保存记录个数
rstByQuery.MoveNext
Loop
MSFlexGrid1.Rows = i + 1 '动态设置MSFlexGrid的行和列
MSFlexGrid1.Cols = rstByQuery.Fields.Count + 1
MSFlexGrid1.Row = 0
For i = 0 To rstByQuery.Fields.Count - 1
MSFlexGrid1.Col = i + 1
MSFlexGrid1.Text = rstByQuery.Fields.Item(i).Name
Next '设置第一行的标题,用域名填充
i = 0
rstByQuery.Requery
Do While Not rstByQuery.EOF
i = i + 1
MSFlexGrid1.Row = i '确定行
For j = 0 To rstByQuery.Fields.Count - 1
MSFlexGrid1.Col = j + 1
MSFlexGrid1.Text = rstByQuery(j) '添充所有的列
Next
rstByQuery.MoveNext
Loop '这个循环用来填充MSFlexGrid的内容
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -