Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Data.SqlClient;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Data.SQLite;
- namespace charp_grafine_2017_01_19
- {
- public partial class Form1 : Form
- {
- private string ConnectionString = "Data Source=duombaze.db;Version=3";
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- using (var con = new SQLiteConnection(ConnectionString))
- {
- try
- {
- con.Open();
- // testavimui
- /* if (con.State == ConnectionState.Open)
- {
- MessageBox.Show("prisijungta");
- }*/
- var sql = "SELECT pavadinimas FROM lentele";
- SQLiteCommand cmd = new SQLiteCommand(sql, con);
- cmd.ExecuteNonQuery();
- SQLiteDataAdapter dataAdt = new SQLiteDataAdapter(cmd);
- dataAdt.SelectCommand = cmd;
- DataTable dbDataSet = new DataTable();
- dataAdt.Fill(dbDataSet);
- BindingSource bsource = new BindingSource();
- bsource.DataSource = dbDataSet;
- //listBox1.DataSource = bsource;
- dataAdt.Update(dbDataSet);
- DataRow tempRow = null;
- foreach (DataRow tempRow_Variable in dbDataSet.Rows)
- {
- tempRow = tempRow_Variable;
- listBox1.Items.Add(tempRow["pavadinimas"]);
- }
- con.Close();
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- throw;
- }
- }
- }
- private void naujasToolStripMenuItem_Click(object sender, EventArgs e)
- {
- naujas forma = new naujas();
- forma.Show();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement