Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TABLE student(
- std_id INTEGER NOT NULL PRIMARY KEY,
- name VARCHAR(40) NOT NULL,
- date VARCHAR(40) ,
- department_id integer references bolum ,
- phone VARCHAR(20),
- scolarship VARCHAR(20));
- CREATE TABLE department(
- department_id INTEGER PRIMARY KEY,
- d_price VARCHAR(20),
- department_name VARCHAR(40));
- (1, 20000, 'Computer Engineering');
- (2, 25000, 'X Engineering');
- (3, 22000, 'Y Engineering');
- (4, 24000, 'Z Engineering');
- (5, 28000, 'K Engineering');
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using FirebirdSql.Data.FirebirdClient;
- namespace prj
- {
- public partial class Form1 : Form
- {
- public string ConnectionString = "User=SYSDBA;Password=masterkey; Database=localhost:D:\db\DB.FDB; DataSource=localhost;";
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- try
- {
- string name= textBox1.Text;
- string phone = textBox2.Text;
- string scolar = textBox3.Text;
- string id = textBox4.Text;
- string date = Convert.ToString(date);
- int department = 1;
- if (comboBox1.Text == "Computer Engineering") department = 1;
- else if (comboBox1.Text == "X Engineering") department = 2;
- else if (comboBox1.Text == "Y Engineering") department = 3;
- else if (comboBox1.Text == "Z Engineering") department = 4;
- else if (comboBox1.Text == "K Engineering") department = 5;
- FbConnection con = new FbConnection(ConnectionString);
- con.Open();
- FbTransaction fbt =con.BeginTransaction();
- string com = "INSERT INTO student(std_id,name,department_id,phone,scolar) values (@std_id,@name,@department_id,@phone,@scolar)";
- FbCommand komut = new FbCommand(com, con, fbt);
- komut.Parameters.AddWithValue("@std_id", id);
- komut.Parameters.AddWithValue("@name", name);
- komut.Parameters.AddWithValue("@department_id", department);
- komut.Parameters.AddWithValue("@phone", phone);
- komut.Parameters.AddWithValue("@scolar", scolar);
- komut.ExecuteNonQuery();
- fbt.Commit();
- con.Close();
- MessageBox.Show(" succesfull");
- }
- catch (Exception x)
- {
- MessageBox.Show(x.Message);
- }
- }
- } }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement