具体代码怎么写的,感觉还是一样的效果。
Private Sub Command1_Click()
Adodc1.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=bd_manpowerinfo"
Adodc1.RecordSource = "select id,name,sex,住址 from dbo.Table_1"
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
End Sub
Private Sub Text1_Click()
sql = "select * form Table_1 where id=" & Val(Text1)
End Sub
修改如下即可:
Private Sub Command1_Click()
Adodc1.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=bd_manpowerinfo"
Adodc1.RecordSource = "select id,name,sex,住址 from dbo.Table_1 where id=" & Val(Text1)
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
End Sub
很少有ID使用字符类型的,修改如下即可:
Private Sub Command1_Click()
Adodc1.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=bd_manpowerinfo"
Adodc1.RecordSource = "select id,name,sex,住址 from dbo.Table_1 where id='" & Val(Text1) & "'"
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
End Sub