SQLite 데이터베이스에 연결하고 싶습니다. 작동하는 예제 코드를 보여주십시오. 또한 나는 database.I이 코드를 사용하여 DataGridView에 연결하고 싶지만 동작하지 않습니다 당신은 System.Data.SQLite ADO.NET 공급자를 사용할 수SQLite 데이터베이스와 C# 응용 프로그램을 연결하는 방법
private DataTable dt;
public Form1()
{
InitializeComponent();
this.dt = new DataTable();
}
private SQLiteConnection SQLiteConnection;
private void DataClass()
{
SQLiteConnection = new SQLiteConnection("Data Source=PasswordManager.s3db;Version=3;");
}
private void GetData()
{
SQLiteDataAdapter DataAdapter;
try
{
SQLiteCommand cmd;
SQLiteConnection.Open(); //Initiate connection to the db
cmd = SQLiteConnection.CreateCommand();
cmd.CommandText = "select*from PasswordManager;"; //set the passed query
DataAdapter = new SQLiteDataAdapter(cmd);
DataAdapter.Fill(dt); //fill the datasource
dataGridView1.DataSource = dt;
}
catch(SQLiteException ex)
{
//Add your exception code here.
}
SQLiteConnection.Close();
지금까지 해보신 것은 무엇입니까? 또한 [이 질문] (http://stackoverflow.com/questions/26020/what-is-the-best-way-to-connect-and-use-a-sqlite-database-from-c-sharp)을 참조하십시오. –
먼저 (uggled) (https://www.google.com/?#q=c%23%20sqlite%20example) 먼저 해 보셨습니까? – Jon