首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VB Dotnet >

FROM子句语法异常

2012-05-30 
FROM子句语法错误!VB code Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System

FROM子句语法错误!

VB code
 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


错误发生在rst.Open("SELECT * FROM User WHERE ID=1", con),报from子句语法错误。

为什么啊?还有,rst.CursorLocation = 1是rst.CursorLocation = adUseClient ,但是报adUseClient未定义错误。是不是需要导入什么类库啊,怎么做?

求各位大神解救!!!

[解决办法]
VB.NET code
SELECT * FROM [User] WHERE ID=1
[解决办法]
user 和id是关键字,需要用[]
SELECT * FROM [User] WHERE [ID]=1
[解决办法]
这是vb6的ado用法,重新用ado.net写比较好

热点排行