Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Data.SqlClient;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. using System.Data.SQLite;
  12.  
  13. namespace charp_grafine_2017_01_19
  14. {
  15. public partial class Form1 : Form
  16. {
  17. private string ConnectionString = "Data Source=duombaze.db;Version=3";
  18.  
  19. public Form1()
  20. {
  21. InitializeComponent();
  22. }
  23.  
  24. private void Form1_Load(object sender, EventArgs e)
  25. {
  26. using (var con = new SQLiteConnection(ConnectionString))
  27. {
  28. try
  29. {
  30. con.Open();
  31.  
  32. // testavimui
  33. /* if (con.State == ConnectionState.Open)
  34. {
  35. MessageBox.Show("prisijungta");
  36. }*/
  37.  
  38. var sql = "SELECT pavadinimas FROM lentele";
  39. SQLiteCommand cmd = new SQLiteCommand(sql, con);
  40. cmd.ExecuteNonQuery();
  41.  
  42. SQLiteDataAdapter dataAdt = new SQLiteDataAdapter(cmd);
  43. dataAdt.SelectCommand = cmd;
  44. DataTable dbDataSet = new DataTable();
  45. dataAdt.Fill(dbDataSet);
  46. BindingSource bsource = new BindingSource();
  47. bsource.DataSource = dbDataSet;
  48. //listBox1.DataSource = bsource;
  49. dataAdt.Update(dbDataSet);
  50. DataRow tempRow = null;
  51.  
  52. foreach (DataRow tempRow_Variable in dbDataSet.Rows)
  53. {
  54. tempRow = tempRow_Variable;
  55. listBox1.Items.Add(tempRow["pavadinimas"]);
  56. }
  57.  
  58. con.Close();
  59. }
  60. catch (Exception ex)
  61. {
  62. MessageBox.Show(ex.Message);
  63. throw;
  64. }
  65. }
  66. }
  67.  
  68. private void naujasToolStripMenuItem_Click(object sender, EventArgs e)
  69. {
  70. naujas forma = new naujas();
  71. forma.Show();
  72. }
  73. }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement