Note that there are some explanatory texts on larger screens.

plurals
  1. POVb.net and MySQL: Unknown column in 'field list'
    primarykey
    data
    text
    <p>i hope you can help me. Fist of all, sorry if my English is annoying, i'm not a native speaker. </p> <p>I'm getting this error and i can't see what i'm doing wrong. I have a program that fills a local MySQL DB with data from another program that uses an OLEB DB. So it compares the tables and upload new data on demand. But i'm getting this error with only one table using the same Sub that i used with other tables. </p> <blockquote> <p>Unknown column 'lpedidos.serie' in 'field list'</p> </blockquote> <p>The problem is that 'lpedidos.serie' exists indeed. So here is the code of the sub, please don't laugh, i know that maybe is extremely inefficient, but i'm just a noob.</p> <pre><code> Public Sub notIndexedTables(table As DataTable, table2 As DataTable, tableNA As String) Dim temptable As DataTable temptable = table.Clone Dim tablename As String = temptable.TableName Dim myAdapter As MySql.Data.MySqlClient.MySqlDataAdapter Dim SQL As String Dim newconn As New MySql.Data.MySqlClient.MySqlConnection newconn = mysqlConnection() newconn.Open() SQL = "TRUNCATE " &amp; tableNA myAdapter = New MySql.Data.MySqlClient.MySqlDataAdapter() Dim command As MySql.Data.MySqlClient.MySqlCommand command = New MySql.Data.MySqlClient.MySqlCommand(SQL, newconn) myAdapter.DeleteCommand = command myAdapter.DeleteCommand.ExecuteNonQuery() For Each row As DataRow In table.Rows() Dim columnNumber As Int32 = row.ItemArray.Count Dim i As Integer = 0 Dim s1 As String = "(" For Each columna In row.ItemArray i = i + 1 If i = columnNumber Then s1 = s1 + CStr(table2.Columns.Item(i - 1).ColumnName) &amp; ")" Else s1 = s1 &amp; CStr(table2.Columns.Item(i - 1).ColumnName) &amp; ", " End If Next Dim s2 As String = "(" i = 0 For i = 0 To (columnNumber - 2) s2 = s2 &amp; "'" &amp; CStr(row.Item(i)) &amp; "', " Next s2 = s2 &amp; "'" &amp; CStr(row.Item(columnNumber - 1)) &amp; "')" SQL = "INSERT INTO " &amp; tableNA &amp; " " &amp; s1 &amp; " VALUES " &amp; s2 myAdapter = New MySql.Data.MySqlClient.MySqlDataAdapter() ' myCommand = New MySql.Data.MySqlClient.MySqlCommandBuilder(myAdapter) command = New MySql.Data.MySqlClient.MySqlCommand(SQL, newconn) myAdapter.InsertCommand = command myAdapter.InsertCommand.ExecuteNonQuery() Next newconn.Close() newconn.Dispose() End Sub </code></pre> <p>Basically it takes the MySQL table (tableNA), truncates it (this procedure is for tables with no index, there is other procedure for tables with unique index) and fills it with the data from the OLEB table (table) and takes the column names from the temporal copy of the MySQL table (table2) (maybe there is no need to use the table2 in this case... but anyway).</p> <p>Here is the exception and the value that SQL string takes when the exception is thrown. <img src="https://i.stack.imgur.com/AMlnh.jpg" alt="exception"></p> <p><img src="https://i.stack.imgur.com/svzZo.jpg" alt="SQL string value"></p> <p>And here is a screenshot of the table structure in phpMyAdmin. <img src="https://i.stack.imgur.com/Xygc3.jpg" alt="lpedidos table structure"></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload