views:

243

answers:

3

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.

A: 

It looks like you have an '=' in your SQL string. Remove that and try it again.

Michael Todd
+1  A: 

There's an error in your SQL query. I believe it should read "SELECT * FROM Articles" (that's minus the equals.)

Bryan Menard
A: 

Thanks for the help. Thats the reason it couldn't fill the dataset...

contactmatt