以下的程序运行后vb提示“属性的使用无效”
DimconnAsNewADODB.ConnectionDimrsAsNewADODB.RecordsetDimcnAsADODB.ConnectionPrivateSu...
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim cn As ADODB.Connection
Private Sub Command1_Click()
If Option1 Then
If Text1 > " " Then
Adodc1.RecordSource = "select * Form Reports where Sno='" & Text1 & "'"
Else
Adodc1.RecordSource = "select * from Reports"
End If
End If
If Option2 Then
If Text1 > " " Then
Adodc1.RecordSource = "select * from Reports where Cno='" & Text1 & "'"
Else
Adodc1.RecordSource = "select * from Reports"
End If
End If
Adodc1.ConnectionString
DataGrid1.Refresh
Adodc1.Refresh
End Sub
Private Sub Form_Load()
conn.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;User ID=Administrative;Initial Catalog=student;Data Source=."
conn.Open
sql = "select * from reports"
rs.CursorLocation = adUseClient
rs.Open sql, conn, adOpenDynamic, adLockBatchOptimistic
Set DataGrid1.DataSource = rs
End Sub 展开
Dim rs As New ADODB.Recordset
Dim cn As ADODB.Connection
Private Sub Command1_Click()
If Option1 Then
If Text1 > " " Then
Adodc1.RecordSource = "select * Form Reports where Sno='" & Text1 & "'"
Else
Adodc1.RecordSource = "select * from Reports"
End If
End If
If Option2 Then
If Text1 > " " Then
Adodc1.RecordSource = "select * from Reports where Cno='" & Text1 & "'"
Else
Adodc1.RecordSource = "select * from Reports"
End If
End If
Adodc1.ConnectionString
DataGrid1.Refresh
Adodc1.Refresh
End Sub
Private Sub Form_Load()
conn.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;User ID=Administrative;Initial Catalog=student;Data Source=."
conn.Open
sql = "select * from reports"
rs.CursorLocation = adUseClient
rs.Open sql, conn, adOpenDynamic, adLockBatchOptimistic
Set DataGrid1.DataSource = rs
End Sub 展开
展开全部
Private Sub Command1_Click()
If Option1 Then
If Text1 > " " Then
sql = "select * Form Reports where Sno='" & Text1 & "'"
Else
sql = "select * from Reports"
End If
End If
If Option2 Then
If Text1 > " " Then
sql = "select * from Reports where Cno='" & Text1 & "'"
Else
sql = "select * from Reports"
End If
End If
rs.CursorLocation = adUseClient
rs.Open sql, conn, adOpenDynamic, adLockBatchOptimistic
Set DataGrid1.DataSource = rs
End Sub
If Option1 Then
If Text1 > " " Then
sql = "select * Form Reports where Sno='" & Text1 & "'"
Else
sql = "select * from Reports"
End If
End If
If Option2 Then
If Text1 > " " Then
sql = "select * from Reports where Cno='" & Text1 & "'"
Else
sql = "select * from Reports"
End If
End If
rs.CursorLocation = adUseClient
rs.Open sql, conn, adOpenDynamic, adLockBatchOptimistic
Set DataGrid1.DataSource = rs
End Sub
追问
我把你的复制也不能运行,有提示“对象打开时,不允许操作”
追答
Private Sub Command1_Click()
If Option1 Then
If Text1 > " " Then
sql = "select * Form Reports where Sno='" & Text1 & "'"
Else
sql = "select * from Reports"
End If
End If
If Option2 Then
If Text1 > " " Then
sql = "select * from Reports where Cno='" & Text1 & "'"
Else
sql = "select * from Reports"
End If
End If
rs.CursorLocation = adUseClient
rs.Open sql, conn, adOpenDynamic, adLockBatchOptimistic
Set DataGrid1.DataSource = rs
rs.Close '..........加这一行
End Sub
Private Sub Form_Load()
conn.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;User ID=Administrative;Initial Catalog=student;Data Source=."
conn.Open
sql = "select * from reports"
rs.CursorLocation = adUseClient
rs.Open sql, conn, adOpenDynamic, adLockBatchOptimistic
Set DataGrid1.DataSource = rs
rs.Close '..........加这一行
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询