我用vb和access做个小系统,怎样通过查询一个字段把该条记录显示在界面的文本框里呢
PrivateSubCX_Click()DimrsAsNewADODB.RecordsetDimstrsqlAsStringDimcnAsNewADODB.Connect...
Private Sub CX_Click()
Dim rs As New ADODB.Recordset
Dim strsql As String
Dim cn As New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db1.mdb"
strsql = "select 学号,姓名,性别,院系,专业 from 学生基本信息表 where 学号='" & Text11.Text & "'"
rs.Open strsql, cn, adOpenStatic, adLockReadOnly, adCmdText
Text1.Text = "" & rs.Fields("学号")
Text2.Text = "" & rs.Fields("姓名")
Text6.Text = "" & rs.Fields("院系")
Text7.Text = "" & rs.Fields("专业")
Text8.Text = "" & rs.Fields("年级")
Text9.Text = "" & rs.Fields("班级")
rs.Close
End Sub
Private Sub Form_Load()
cmbCX.AddItem "按学号查询"
cmbCX.AddItem "按姓名查询"
End Sub
请帮我修改一下,拜托大家了 展开
Dim rs As New ADODB.Recordset
Dim strsql As String
Dim cn As New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db1.mdb"
strsql = "select 学号,姓名,性别,院系,专业 from 学生基本信息表 where 学号='" & Text11.Text & "'"
rs.Open strsql, cn, adOpenStatic, adLockReadOnly, adCmdText
Text1.Text = "" & rs.Fields("学号")
Text2.Text = "" & rs.Fields("姓名")
Text6.Text = "" & rs.Fields("院系")
Text7.Text = "" & rs.Fields("专业")
Text8.Text = "" & rs.Fields("年级")
Text9.Text = "" & rs.Fields("班级")
rs.Close
End Sub
Private Sub Form_Load()
cmbCX.AddItem "按学号查询"
cmbCX.AddItem "按姓名查询"
End Sub
请帮我修改一下,拜托大家了 展开
展开全部
Private Sub CX_Click()
Dim rs As New ADODB.Recordset
Dim strsql As String
Dim cn As New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db1.mdb"
strsql = "select 学号,姓名,性别,院系,专业 from 学生基本信息表 where 学号= " & Text11.Text & " order by 学号"
rs.Open strsql, cn, adOpenStatic, adLockReadOnly, adCmdText
Text1.Text = "" & rs.Fields("学号")
Text2.Text = "" & rs.Fields("姓名")
Text6.Text = "" & rs.Fields("院系")
Text7.Text = "" & rs.Fields("专业")
Text8.Text = "" & rs.Fields("年级")
Text9.Text = "" & rs.Fields("班级")
rs.Close
End Sub
Private Sub Form_Load()
cmbCX.AddItem "按学号查询"
cmbCX.AddItem "按姓名查询"
End Sub
Dim rs As New ADODB.Recordset
Dim strsql As String
Dim cn As New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db1.mdb"
strsql = "select 学号,姓名,性别,院系,专业 from 学生基本信息表 where 学号= " & Text11.Text & " order by 学号"
rs.Open strsql, cn, adOpenStatic, adLockReadOnly, adCmdText
Text1.Text = "" & rs.Fields("学号")
Text2.Text = "" & rs.Fields("姓名")
Text6.Text = "" & rs.Fields("院系")
Text7.Text = "" & rs.Fields("专业")
Text8.Text = "" & rs.Fields("年级")
Text9.Text = "" & rs.Fields("班级")
rs.Close
End Sub
Private Sub Form_Load()
cmbCX.AddItem "按学号查询"
cmbCX.AddItem "按姓名查询"
End Sub
展开全部
Private Sub CX_Click()
Dim rs As New ADODB.Recordset
Dim strsql As String
Dim cn As New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db1.mdb"
strsql = "select * from 学生基本信息表 where 学号='" & Text11.Text & "'"
rs.Open strsql, cn, adOpenStatic, adOpenKeyset, adLockOptimistic
Text1.Text = rs.Fields("学号")
Text2.Text = rs.Fields("姓名")
Text6.Text = rs.Fields("院系")
Text7.Text = rs.Fields("专业")
Text8.Text = rs.Fields("年级")
Text9.Text = rs.Fields("班级")
rs.Close
End Sub
Dim rs As New ADODB.Recordset
Dim strsql As String
Dim cn As New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db1.mdb"
strsql = "select * from 学生基本信息表 where 学号='" & Text11.Text & "'"
rs.Open strsql, cn, adOpenStatic, adOpenKeyset, adLockOptimistic
Text1.Text = rs.Fields("学号")
Text2.Text = rs.Fields("姓名")
Text6.Text = rs.Fields("院系")
Text7.Text = rs.Fields("专业")
Text8.Text = rs.Fields("年级")
Text9.Text = rs.Fields("班级")
rs.Close
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询