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.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Data.SqlClient;
- namespace WindowsFormsApplication1
- {
- public partial class Form1 : Form
- {
- static string _con0 = "Data Source=UC202-UCITEL\\SQLEXPRESS;Initial Catalog=Poliklinika;Integrated Security=SSPI";
- static SqlConnection _con = new SqlConnection(_con0);
- public Form1()
- {
- InitializeComponent();
- List<string> jaj;
- jaj = Select_Pacient(_con0); // 0a) Select orig
- Console.WriteLine("\n0)Orig:");
- //with_Items_AddRange_DataSource();
- //with_Items_Add();
- }
- void with_Items_AddRange_DataSource()
- {
- string[] x = new string[4];
- x[0] = "1";
- x[1] = "2";
- x[2] = "11";
- x[3] = "22";
- //listBox1.Items.AddRange(x);// by default no item is selected
- listBox1.DataSource = x; // by default the first item is selected
- }
- void with_Items_Add()
- {
- string[] x = new string[4];
- x[0] = "1";
- x[1] = "2";
- x[2] = "11";
- x[3] = "22";
- for (int i = 0; i < x.Length; i++)
- listBox1.Items.Add(x[i]); // by default the first item is selected
- }
- public List<string> Select_Pacient(string con0)
- {
- SqlConnection con = new SqlConnection(con0);
- //string s = "Select CompanyName from Customers";
- string s = "Select krstne from pacienti where idP >= 3";
- //string s = "Select krstne from lekari where idL >= 3";
- //string s = "Select spec from lekari where idL >= 3";
- SqlCommand cmd = new SqlCommand(s, con);
- con.Open();
- SqlDataReader read;
- read = cmd.ExecuteReader(CommandBehavior.CloseConnection);
- List<string> x = new List<string>();
- while (read.Read())
- {
- //x.Add(read["krstne"].ToString());
- //x.Add(read["spec"].ToString());
- listBox1.Items.Add(read["krstne"].ToString());
- }
- con.Close();
- return x;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement