Note that there are some explanatory texts on larger screens.

plurals
  1. POSQLiteDataAdapter Update method returning 0
    primarykey
    data
    text
    <p>I loaded 83 rows from my CSV file, but when I try to update the SQLite database I get 0 rows... I can't figure out what I'm doing wrong.</p> <p>The program outputs: </p> <pre><code>Num rows loaded is 83 Num rows updated is 0 </code></pre> <p>The source code is: </p> <pre><code>public void InsertData(String csvFileName, String tableName) { String dir = Path.GetDirectoryName(csvFileName); String name = Path.GetFileName(csvFileName); using (OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + dir + @";Extended Properties=""Text;HDR=Yes;FMT=Delimited""")) { conn.Open(); using (OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM " + name, conn)) { QuoteDataSet ds = new QuoteDataSet(); adapter.Fill(ds, tableName); Console.WriteLine("Num rows loaded is " + ds.Tags.Rows.Count); InsertData(ds, tableName); } } } public void InsertData(QuoteDataSet data, String tableName) { using (SQLiteConnection conn = new SQLiteConnection(_connectionString)) { using (SQLiteDataAdapter sqliteAdapter = new SQLiteDataAdapter("SELECT * FROM " + tableName, conn)) { using (new SQLiteCommandBuilder(sqliteAdapter)) { conn.Open(); Console.WriteLine("Num rows updated is " + sqliteAdapter.Update(data, tableName)); } } } } </code></pre> <p>Any hints on why it's not updating the correct number of rows?</p> <p><strong>Update:</strong> </p> <p>I tried to set the command before calling update and I'm still getting the same issue... the code is now: </p> <pre><code>sqliteAdapter.InsertCommand = cmndBldr.GetInsertCommand(); Console.WriteLine("Num rows updated is " + sqliteAdapter.Update(data, tableName)); </code></pre> <p>When I debug it the command text is: <code>_commandText = "INSERT INTO [Tags] ([tagId], [tagName], [description], [colName], [dataType], [realTime]) VALUES (@param1, @param2, @param3, @param4, @param5, @param6)"</code></p> <p>Here is a pastie showing the state of dataset in xml format: <a href="http://pastie.org/936882" rel="nofollow noreferrer">http://pastie.org/936882</a></p>
    singulars
    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.
 

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