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?
Update:
I tried to set the command before calling update and I'm still getting the same issue... the code is now:
sqliteAdapter.InsertCommand = cmndBldr.GetInsertCommand();
Console.WriteLine("Num rows updated is " + sqliteAdapter.Update(data, tableName));
When I debug it the command text is: _commandText = "INSERT INTO [Tags] ([tagId], [tagName], [description], [colName], [dataType], [realTime]) VALUES (@param1, @param2, @param3, @param4, @param5, @param6)"
Here is a pastie showing the state of dataset in xml format: http://pastie.org/936882