我的想法是:在text1里输入SQL语句
按command1是 就执行该语句 从而在ADODC和DataGrid里反应出来
可是按了居然没反映
SQL语句肯定写的是对的
问题出在哪了呢???
代码如下(D就是DataGrid)
Private Sub Command1_Click()
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Administrator\桌面\vb\db\db1.mdb;Persist Security Info=False"
If Text1.Text = "" Then
MsgBox ("请输入SQL语句")
End If
Exit Sub
Adodc1.RecordSource = Text1.Text
Adodc1.Refresh
D.Refresh
End Sub
Private Sub Form_Load()
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Administrator\桌面\vb\db\db1.mdb;Persist Security Info=False"
Adodc1.RecordSource = "SELECT * FROM dic"
Adodc1.Refresh
D.Refresh
End Sub
參考答案:你在按钮事件里并没有指定
Adodc1.RecordSource 的SQL语句啊
当然就没有执行了