Różnice między wybraną wersją a wersją aktualną.
Poprzednia wersja | |||
— | c-sharp-pgsqconn [2018/07/16 11:47] (aktualna) – edycja zewnętrzna 127.0.0.1 | ||
---|---|---|---|
Linia 1: | Linia 1: | ||
+ | ===== C Sharp - PostgreSQL connector ===== | ||
+ | < | ||
+ | using Npgsql; | ||
+ | |||
+ | . | ||
+ | . | ||
+ | . | ||
+ | |||
+ | mojaKlasa m = new mojaKlasa(); | ||
+ | NpgsqlConnection conn = new NpgsqlConnection(m.connectString()); | ||
+ | try | ||
+ | { | ||
+ | conn.Open(); | ||
+ | NpgsqlCommand command = new NpgsqlCommand(" | ||
+ | NpgsqlDataReader dr = command.ExecuteReader(); | ||
+ | while (dr.Read()) | ||
+ | { | ||
+ | typFrazy.Items.Add(new MyListBoxItemValue(dr.GetString(1), | ||
+ | } | ||
+ | dr.Close(); | ||
+ | command = new NpgsqlCommand(" | ||
+ | dr = command.ExecuteReader(); | ||
+ | int a = 1; | ||
+ | string[] row = new string[7]; | ||
+ | while (dr.Read()) | ||
+ | { | ||
+ | row[0] = a.ToString(); | ||
+ | row[1] = dr.GetString(1); | ||
+ | row[2] = dr.GetString(2); | ||
+ | row[3] = dr.GetInt32(3).ToString(); | ||
+ | row[4] = dr.GetInt64(4).ToString(); | ||
+ | row[5] = dr.GetString(5); | ||
+ | row[6] = dr.GetInt32(0).ToString(); | ||
+ | tabSprzetu.Rows.Add(row); | ||
+ | a++; | ||
+ | } | ||
+ | } | ||
+ | catch (Exception ee) | ||
+ | { | ||
+ | MessageBox.Show(" | ||
+ | } | ||
+ | finally | ||
+ | { | ||
+ | conn.Close(); | ||
+ | } | ||
+ | |||
+ | . | ||
+ | . | ||
+ | . | ||
+ | |||
+ | mojaKlasa m = new mojaKlasa(); | ||
+ | NpgsqlConnection conn = new NpgsqlConnection(m.connectString()); | ||
+ | try | ||
+ | { | ||
+ | MyListBoxItemValue typ0 = (MyListBoxItemValue)typ.SelectedItem; | ||
+ | conn.Open(); | ||
+ | NpgsqlCommand command = new NpgsqlCommand(" | ||
+ | command.Parameters.Add(new NpgsqlParameter(" | ||
+ | command.Parameters.Add(new NpgsqlParameter(" | ||
+ | command.Parameters.Add(new NpgsqlParameter(" | ||
+ | command.Parameters.Add(new NpgsqlParameter(" | ||
+ | command.Parameters.Add(new NpgsqlParameter(" | ||
+ | command.Parameters.Add(new NpgsqlParameter(" | ||
+ | command.Parameters[0].Value = nazwa.Text; | ||
+ | command.Parameters[1].Value = opis.Text; | ||
+ | command.Parameters[2].Value = typ0.ItemData; | ||
+ | command.Parameters[3].Value = nrSer.Text; | ||
+ | command.Parameters[4].Value = int.Parse(ilosc.Text); | ||
+ | command.Parameters[5].Value = nrInw.Text; | ||
+ | command.ExecuteNonQuery(); | ||
+ | } | ||
+ | catch (Exception ee) | ||
+ | { | ||
+ | MessageBox.Show(" | ||
+ | } | ||
+ | finally | ||
+ | { | ||
+ | conn.Close(); | ||
+ | } | ||
+ | </ |