vb运行时总是报错说连接无法用于执行此操作,在此上下文中它可能已经被关闭或者无效
PrivateSubCommand1_Click()DimcnAsNewADODB.ConnectionDimrsAsNewADODB.RecordsetDimstrcn...
Private Sub Command1_Click()
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim strcnn As String
Dim strquery As String
strcnn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\asycad\rsgl.mdb;Persist Security Info=False"
Set cn = New ADODB.Connection
cn.Open strcnn
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.CursorType = adOpenStatic
rs.LockType = adLockBatchOptimistic
strquery = "select * from 职工基本情况 where 编号='100001'"
rs.Open strquery
Text1.Text = rs.Fields(1)
rs.Close
cn.Close 展开
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim strcnn As String
Dim strquery As String
strcnn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\asycad\rsgl.mdb;Persist Security Info=False"
Set cn = New ADODB.Connection
cn.Open strcnn
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.CursorType = adOpenStatic
rs.LockType = adLockBatchOptimistic
strquery = "select * from 职工基本情况 where 编号='100001'"
rs.Open strquery
Text1.Text = rs.Fields(1)
rs.Close
cn.Close 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询