帮助:MySQL 适配器.填充(数据集)错误
我正在使用 MySqlClient 类连接到 MySQL 数据库。当我尝试使用数据集填充数据列表时,出现错误:
#42000您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册以获取正确的语法
这是我在 VB.net 中用于填充数据列表的代码。
Dim strConn As String = "server=name;uid=un;pwd=pass;database=db"
Dim myConnection As New MySqlConnection(strConn)
Dim strSQL As String = "SELECT * FROM Articles = "
Dim myDataAdapter As New MySqlDataAdapter(strSQL, myConnection)
Dim ds As New DataSet()
myConnection.Open()
myDataAdapter.Fill(ds, "Articles")
MyDataList.DataSource = ds
myconnection.close()
这是 DataList 控件的代码
<ASP:DataList id="MyDataList" runat="server">
<ItemTemplate>
Title:
<%# DataBinder.Eval(Container.DataItem, "title")%>
<br>
<b>Author: </b>
<%#DataBinder.Eval(Container.DataItem, "Author")%><br>
<b>PubDate: </b>
<%#DataBinder.Eval(Container.DataItem, "PubDate")%><br>
<p>
</ItemTemplate>
</ASP:DataList>
连接工作正常,我能够获取值;但我无法填写此数据列表。
I'm connecting to a MySQL database using the MySqlClient class. When I try to fill a fill a Data List with the Data Set I get an error:
#42000You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax
Heres the code I have in VB.net to fill the data list.
Dim strConn As String = "server=name;uid=un;pwd=pass;database=db"
Dim myConnection As New MySqlConnection(strConn)
Dim strSQL As String = "SELECT * FROM Articles = "
Dim myDataAdapter As New MySqlDataAdapter(strSQL, myConnection)
Dim ds As New DataSet()
myConnection.Open()
myDataAdapter.Fill(ds, "Articles")
MyDataList.DataSource = ds
myconnection.close()
Heres the Code for the DataList Control
<ASP:DataList id="MyDataList" runat="server">
<ItemTemplate>
Title:
<%# DataBinder.Eval(Container.DataItem, "title")%>
<br>
<b>Author: </b>
<%#DataBinder.Eval(Container.DataItem, "Author")%><br>
<b>PubDate: </b>
<%#DataBinder.Eval(Container.DataItem, "PubDate")%><br>
<p>
</ItemTemplate>
</ASP:DataList>
The connection works fine, and I am able to grab values; but I cannot fill this Data List.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的 SQL 查询中有错误。我相信它应该是
“SELECT * FROM Articles”
(减去等号。)There's an error in your SQL query. I believe it should read
"SELECT * FROM Articles"
(that's minus the equals.)看起来您的 SQL 字符串中有一个“=”。删除它并重试。
It looks like you have an '=' in your SQL string. Remove that and try it again.