#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
Tutorial C# Bulk inserts
-
- Devart Team
- Posts: 2420
- Joined: Wed 02 Nov 2011 09:44
Re: Tutorial C# Bulk inserts
Could you please post the code with the foreach loop or send us a test project with the corresponding database?onwww.org wrote:I am attempting to insert from a foreach loop into the database
Could you please specify what you mean by saying "sql file", what it is locked by, and for how long it is locked?onwww.org wrote:so I named the parameters and now the sql file is locked.
The snippet of code where you use the named and unnamed parameters works correctly. The database file is locked because the connection is present in the pool: http://www.devart.com/dotconnect/sqlite ... Q.html#q52
Could you please state your question more accurately, as we couldn't get from your post what exactly worked wrong or what was your question.