Hello,
I need to evaluate LinqConnect with SQLite. One of the things we need to do is be able to create a new md file in code from our model (model first). Could someone show me a some code that would allow us to do this?
Thanks!
SQLite - how to create
Re: SQLite - how to create
I'm gonna answer my own question...
This code works:
System.Data.SQLite.SQLiteConnection.CreateFile("c:\\temp\\temp.db3");
DataContext1 d = new DataContext1("Data Source=C:\\temp\\temp.db3");
d.Connection.Open();
d.CreateDatabase(false, true);
d.SubmitChanges();
Class1 c = new Class1();
c.Property1 = "hi";
c.Property2 = "sfd";
d.Class1s.InsertOnSu(c);
d.SubmitChanges();
I was having a issue since I wasn't using hte very first line of code.
This code works:
System.Data.SQLite.SQLiteConnection.CreateFile("c:\\temp\\temp.db3");
DataContext1 d = new DataContext1("Data Source=C:\\temp\\temp.db3");
d.Connection.Open();
d.CreateDatabase(false, true);
d.SubmitChanges();
Class1 c = new Class1();
c.Property1 = "hi";
c.Property2 = "sfd";
d.Class1s.InsertOnSu(c);
d.SubmitChanges();
I was having a issue since I wasn't using hte very first line of code.
Re: SQLite - how to create
There is no need in these lines in your code:
and
New database file will be created and the connection will be opened automatically when performing the CreateDatabase(false,true) method. Please refer to:
http://www.devart.com/linqconnect/docs/?DDL.html
http://www.devart.com/linqconnect/docs/ ... lean).html
Rewrite your code in the following way:
You can try monitoring your application via the dbMonitor tool to see the results. For example:
For more information please refer to
http://www.devart.com/linqconnect/docs/?Monitoring.html
http://www.devart.com/linqconnect/docs/ ... nitor.html
Please tell us about the results.
Code: Select all
System.Data.SQLite.SQLiteConnection.CreateFile("c:\\temp\\temp.db3"); // JIC: you can use Devart.Data.SQLite.SQLiteConnection for such cases
Code: Select all
d.Connection.Open();
///
d.SubmitChanges();
http://www.devart.com/linqconnect/docs/?DDL.html
http://www.devart.com/linqconnect/docs/ ... lean).html
Rewrite your code in the following way:
Code: Select all
DataContext d = new DataContext("Data Source=c:\\temp\\temp.db3");
d.CreateDatabase(false, true);
Class1 c = new Class1();
c.Property1 = "hi";
c.Property2 = "sfd";
d.Class1s.InsertOnSubmit(c);
d.SubmitChanges();
Code: Select all
Devart.Data.Linq.Monitoring.LinqMonitor lm = new Devart.Data.Linq.Monitoring.LinqMonitor(){ isActive = true };
http://www.devart.com/linqconnect/docs/?Monitoring.html
http://www.devart.com/linqconnect/docs/ ... nitor.html
Please tell us about the results.
Re: SQLite - how to create
Thanks that worked. Also thanks for pointing out dbmonitor. That will definitely be useful in the future.
Re: SQLite - how to create
If you have any further questions, feel free to contact us.