FROM子句语法错误!
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim con As ADODB.Connection Dim rst As ADODB.Recordset Dim str As String con = New ADODB.Connection rst = New ADODB.Recordset rst.CursorLocation = 1 str = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Users\user\Documents\Visual Studio 2010\Projects\ConnectionDB\ConnectionDB\STUDENT.mdb" con.Open(str) rst.Open("SELECT * FROM User WHERE ID=1", con) Me.Text = rst.Fields.Count End Sub
SELECT * FROM [User] WHERE ID=1
[解决办法]
user 和id是关键字,需要用[]
SELECT * FROM [User] WHERE [ID]=1
[解决办法]
这是vb6的ado用法,重新用ado.net写比较好