以下的程序运行后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
展开
 我来答
网海1书生
科技发烧友

2011-11-28 · 擅长软件设计、WEB应用开发、小程序
网海1书生
采纳数:12311 获赞数:26230

向TA提问 私信TA
展开全部
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
追问
我把你的复制也不能运行,有提示“对象打开时,不允许操作”
追答
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
大山说桥架
2011-11-27 · TA获得超过250个赞
知道小有建树答主
回答量:350
采纳率:33%
帮助的人:85.8万
展开全部
Adodc1.ConnectionString
这句不对,应为adodc1.refresh
追问
这也不行   不过还是谢谢你了
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
daxishen
2011-11-27 · 超过19用户采纳过TA的回答
知道答主
回答量:116
采纳率:0%
帮助的人:60.4万
展开全部
Adodc1属性没有设置好。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式