Tutorial C# Bulk inserts
Posted: Sun 20 May 2012 15:52
#1 Thank you for a great product
#2 I have had difficultly setting up the product.
I understand that you supply your product for developers, but if you target young developers maybe you will get more usage.
I am attempting to insert from a foreach loop into the database
In the example you gave in the help file
using Devart.Data.SQLite;
try
{
SQLiteConnection conn = new SQLiteConnection("Data Source=MainDataBase.db");
SQLiteCommand cmd = new SQLiteCommand();
conn.Open();
var insertSQL = new SQLiteCommand("INSERT INTO ValuesTBL (Value1,DateAdded) VALUES (@uNavnParam, @bNavnParam)", conn);
insertSQL.Parameters.AddWithValue("@uNavnParam", val1org);
insertSQL.Parameters.AddWithValue("@bNavnParam", val1org);
insertSQL.ExecuteNonQuery(); //Exe
//cmd.CommandText = "INSERT INTO ValuesTBL (Value1,DateAdded) VALUES (?, ?)";
//cmd.Parameters.Add("param1", val1org);
//cmd.Parameters.Add("param2", DateTime.Now.ToString());
//cmd.Connection = conn;
conn.Open();
try
{
//// MessageBox.Show();
// int aff = cmd.ExecuteNonQuery();
// MessageBox.Show(aff + " rows were affected.");
}
catch (Exception ex)
{
DataLogEntry("Application Error", ex.ToString());
MessageBox.Show("Error encountered during INSERT operation.");
throw new Exception();
}
finally
{
conn.Close();
}
in the trace the query remains INSERT INTO ValuesTBL (Value1,DateAdded) VALUES (?, ?)
http://www.devart.com/dotconnect/sqlite ... eters.html
so I named the parameters and now the sql file is locked
#2 I have had difficultly setting up the product.
I understand that you supply your product for developers, but if you target young developers maybe you will get more usage.
I am attempting to insert from a foreach loop into the database
In the example you gave in the help file
using Devart.Data.SQLite;
try
{
SQLiteConnection conn = new SQLiteConnection("Data Source=MainDataBase.db");
SQLiteCommand cmd = new SQLiteCommand();
conn.Open();
var insertSQL = new SQLiteCommand("INSERT INTO ValuesTBL (Value1,DateAdded) VALUES (@uNavnParam, @bNavnParam)", conn);
insertSQL.Parameters.AddWithValue("@uNavnParam", val1org);
insertSQL.Parameters.AddWithValue("@bNavnParam", val1org);
insertSQL.ExecuteNonQuery(); //Exe
//cmd.CommandText = "INSERT INTO ValuesTBL (Value1,DateAdded) VALUES (?, ?)";
//cmd.Parameters.Add("param1", val1org);
//cmd.Parameters.Add("param2", DateTime.Now.ToString());
//cmd.Connection = conn;
conn.Open();
try
{
//// MessageBox.Show();
// int aff = cmd.ExecuteNonQuery();
// MessageBox.Show(aff + " rows were affected.");
}
catch (Exception ex)
{
DataLogEntry("Application Error", ex.ToString());
MessageBox.Show("Error encountered during INSERT operation.");
throw new Exception();
}
finally
{
conn.Close();
}
in the trace the query remains INSERT INTO ValuesTBL (Value1,DateAdded) VALUES (?, ?)
http://www.devart.com/dotconnect/sqlite ... eters.html
so I named the parameters and now the sql file is locked