Dim cnn As New ADODB.Connection Dim rs As New ADODB.Recordset cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\qn\My Documents\Visual Studio 2005\Projects\vbexercise\vbexercise\Jet 4.0.mdb"
cnn.CursorLocation = adUseClient
cnn.Open() rs.Open("Select A.社员CD,A.社员カナ,A.社员名,B.部门名 From 社员 A,部门 B where b.部门cd = a.部门cd", cnn, 3, 3) Me.DGV社员Show.DataSource = rs Me.DGV社员Show.Refresh()
为什么就是显示不了数据呢??
最新回答
咸鱼味的猫
2024-06-24 03:33:44
Private myCon As New OleDbConnection Private mycmd As New OleDbCommand Private myada As New OleDbDataAdapter myCon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & CurDir() & "\Jet 4.0.mdb" myCon.Open() mycmd.CommandText ="Select A.社员CD,A.社员カナ,A.社员名,B.部门名 From 社员 A,部门 B where b.部门cd = a.部门cd" mycmd.Connection = myCon myada.SelectCommand = mycmd myds.Clear() myada.Fill(myds, "表名") Me.DGV社员Show.DataSource = myada Me.DGV社员Show.Refresh()
添加一个adodc控件 Dim cnn As New ADODB.Connection Dim rs As New ADODB.Recordset cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\qn\My Documents\Visual Studio 2005\Projects\vbexercise\vbexercise\Jet 4.0.mdb"
Adodc1.ConnectionString = CnnStr Adodc1.CommandType = adCmdText Adodc1.RecordSource = "select A.社员CD,A.社员カナ,A.社员名,B.部门名 From 社员 A,部门 B where b.部门cd = a.部门cd" adodc1.refresh Set DataGrid1.DataSource = Adodc1 DataGrid1.Refresh