Nikola Stanchev Публикувано Януари 8, 2012 Report Share Публикувано Януари 8, 2012 Здравейте! Искам да свържа SQLite база данни с C# приложение, но имам проблеми.Опитах с този код, но datagridview-a не се зарежда. Помощ! using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data.SQLite; namespace PasswordManager { public partial class Form1 : Form { 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(); } Цитирай Link to comment Сподели другаде More sharing options...
Препоръчан пост
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.