Advertisement
Guest User

Untitled

a guest
Mar 10th, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. CREATE TABLE student(
  2. std_id INTEGER NOT NULL PRIMARY KEY,
  3. name VARCHAR(40) NOT NULL,
  4. date VARCHAR(40) ,
  5. department_id integer references bolum ,
  6. phone VARCHAR(20),
  7. scolarship VARCHAR(20));
  8.  
  9.  
  10. CREATE TABLE department(
  11. department_id INTEGER PRIMARY KEY,
  12. d_price VARCHAR(20),
  13. department_name VARCHAR(40));
  14.  
  15. (1, 20000, 'Computer Engineering');
  16. (2, 25000, 'X Engineering');
  17. (3, 22000, 'Y Engineering');
  18. (4, 24000, 'Z Engineering');
  19. (5, 28000, 'K Engineering');
  20.  
  21. using System;
  22. using System.Collections.Generic;
  23. using System.ComponentModel;
  24. using System.Data;
  25. using System.Drawing;
  26. using System.Linq;
  27. using System.Text;
  28. using System.Threading.Tasks;
  29. using System.Windows.Forms;
  30. using FirebirdSql.Data.FirebirdClient;
  31.  
  32. namespace prj
  33. {
  34. public partial class Form1 : Form
  35. {
  36.  
  37. public string ConnectionString = "User=SYSDBA;Password=masterkey; Database=localhost:D:\db\DB.FDB; DataSource=localhost;";
  38.  
  39. public Form1()
  40. {
  41. InitializeComponent();
  42. }
  43.  
  44. private void button1_Click(object sender, EventArgs e)
  45. {
  46. try
  47. {
  48.  
  49. string name= textBox1.Text;
  50. string phone = textBox2.Text;
  51. string scolar = textBox3.Text;
  52. string id = textBox4.Text;
  53. string date = Convert.ToString(date);
  54. int department = 1;
  55.  
  56.  
  57.  
  58. if (comboBox1.Text == "Computer Engineering") department = 1;
  59. else if (comboBox1.Text == "X Engineering") department = 2;
  60. else if (comboBox1.Text == "Y Engineering") department = 3;
  61. else if (comboBox1.Text == "Z Engineering") department = 4;
  62. else if (comboBox1.Text == "K Engineering") department = 5;
  63.  
  64.  
  65.  
  66. FbConnection con = new FbConnection(ConnectionString);
  67. con.Open();
  68. FbTransaction fbt =con.BeginTransaction();
  69.  
  70.  
  71. string com = "INSERT INTO student(std_id,name,department_id,phone,scolar) values (@std_id,@name,@department_id,@phone,@scolar)";
  72.  
  73. FbCommand komut = new FbCommand(com, con, fbt);
  74.  
  75.  
  76. komut.Parameters.AddWithValue("@std_id", id);
  77. komut.Parameters.AddWithValue("@name", name);
  78.  
  79. komut.Parameters.AddWithValue("@department_id", department);
  80. komut.Parameters.AddWithValue("@phone", phone);
  81. komut.Parameters.AddWithValue("@scolar", scolar);
  82.  
  83. komut.ExecuteNonQuery();
  84. fbt.Commit();
  85. con.Close();
  86. MessageBox.Show(" succesfull");
  87. }
  88. catch (Exception x)
  89. {
  90. MessageBox.Show(x.Message);
  91. }
  92.  
  93.  
  94. }
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102. } }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement