I want to develop small application in asp.net using sqlite, actually I don’t know how to use sqlite in application. Can anybody provide a link for step by step process to create a application in asp.net code behind c#.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
You create it the same way you would any regular asp.net web application – You probably want to use a provider for it, such as this: http://system.data.sqlite.org/
Here is how to make the connection: http://www.fryan0911.com/2009/10/c-how-to-connect-to-sqlite-database.html
More information about sqlite functionality here: http://www.aspfree.com/c/a/Database/Using-SQLite-for-Simple-Database-Storage/
There are certain subtleties that is different than regular sql server – you can read about it on that site. Here is another question that has some information on these subtle differences: https://stackoverflow.com/questions/822548/c-sqlite-syntax-in-asp-net
Method 2
This guide should get you started:
Using SQLite in your C# Application
Ultimately using SQLite is very similar to using Microsoft SQL Server, just with different objects and an extra assembly reference.
Method 3
Try to this code
public class DBhelperClass
{
string dbConnection = "Data Source=ShyamDB.s3db";
public DataTable GetDataTable(string sql) {
DataTable dt = new DataTable();
try {
SQLiteConnection cnn = new SQLiteConnection(dbConnection);
cnn.Open();
SQLiteCommand mycommand = new SQLiteCommand(cnn);
mycommand.CommandText = sql;
SQLiteDataReader reader = mycommand.ExecuteReader();
dt.Load(reader);
reader.Close();
cnn.Close();
} catch (Exception e) {
throw new Exception(e.Message);
}
return dt;
}
}
//string nputFile = "ShyamDB.s3db" is mydb name ;
DBhelperClass db = new DBhelperClass();
dataGridView1.DataSource = db.GetDataTable("Select * from ShyamTable");
Final result loads in DataGridView.
Method 4
Use this for connect to sqlite
http://system.data.sqlite.org/
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0