SQLiteDataAdapter Update method returning 0
- by Lirik
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.
The program outputs:
Num rows loaded is 83
Num rows updated is 0
The source code is:
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));
}
}
}
}
Any hints on why it's not updating the correct number of rows?