Advertisement
Guest User

bogda

a guest
May 20th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Data.OleDb;
  9. using System.Windows.Forms;
  10.  
  11. namespace WindowsFormsApplication1
  12. {
  13. public partial class Form1 : Form
  14. {
  15. public Form1()
  16. {
  17. InitializeComponent();
  18. }
  19.  
  20. private void Form1_Load(object sender, EventArgs e)
  21. {
  22. dataGridView1.ColumnCount = 6;
  23. dataGridView1.Columns[0].HeaderText = "cod_cl";
  24. dataGridView1.Columns[1].HeaderText = "sala";
  25. dataGridView1.Columns[2].HeaderText = "profil";
  26. dataGridView1.Columns[3].HeaderText = "specialitate";
  27. dataGridView1.Columns[4].HeaderText = "diriginte";
  28. dataGridView1.Columns[5].HeaderText = "nr_elevi";
  29.  
  30. //stringul de conectare
  31. string connstring =@"Provider-Microsoft.ACE.OLEDB.12.0; Data Source=scoala11a.accdb";
  32. //stringul de interogare
  33. string sql=@"select * from Clase";
  34. //declarare variabilele conexiune si data reader
  35. OleDbConnection conn=null;
  36. OleDbConnection reader=null;
  37. //cream conexiunea
  38. using (conn=new OleDbConnection(connstring))
  39. { conn.Open();
  40. //se executa interogarea
  41. OleDbCommand cmd=new OleDbCommand(sql,conn);
  42. reader= cmd.ExecuteReader();
  43. //declaram un tablou de stringuri care retine val. unui rand din tabela
  44. string[] r=null;
  45. //met. Read() avanseaza reader la un rand nou
  46. while(reader.Read())
  47. {r=new string[6] {
  48.  
  49.  
  50.  
  51. }
  52.  
  53.  
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement