Creating database



(1)

1.(A) Creating database

Create database emp

Creating table

Create tablae employee

(

employee_name varchar(50),

street varchar(50),

city varchar(50)

)

Create tablae works

(

employee_name varchar(50),

company_name varchar(50),

salary int(50)

)

Create tablae company

(

company_name varchar(50),

city varchar(50)

)

1(B) Procedure to input data into employee table

create procedure insert_into_employee

@employee_name varchar(50),

@street varchar(50),

@city varchar(50)

as insert into emp values

(

@employee_name ,

@street ,

@city

)

Here the procedure is called to insert data in to the table employee

————————–insert_into_employee’Rehana’,’Green Road’,’Tangail’

Find the name, cities and salaries of all employee who works for prime bank

select employee.employee_name,street,city,salary

from employee,works

where company_name = ‘prime bank’

1(C) Employee form design:

clip_image002

private void Add_data()

{

conn ob = new conn();

SqlConnection obcon = new SqlConnection(ob.strconn);

SqlCommand cmd = new SqlCommand(“insert_into_employee”, obcon);

cmd.CommandType = CommandType.StoredProcedure;

DialogResult result = MessageBox.Show(“Do you want to save change?”, “employee”, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

if (result == DialogResult.Yes)

{

cmd.Parameters.Add(“@employee_name”, SqlDbType.VarChar, 50);

cmd.Parameters.Add(“@street”, SqlDbType.VarChar, 50);

cmd.Parameters.Add(“@city”, SqlDbType.VarChar, 50);

//cmd.Parameters[“@invoice”].Value = textinovice.Text;

cmd.Parameters[“@employee_name”].Value = txtempname.Text;

cmd.Parameters[“@street”].Value = txtstreet.Text;

cmd.Parameters[“@city”].Value = txtcity.Text;

obcon.Open();

cmd.ExecuteNonQuery();

obcon.Close();

}

MessageBox.Show(“Data Saved Successfully”);

txtempname.Text = “”;

txtstreet.Text = “”;

txtcity.Text = “”;

}

1(D) Report design

clip_image004

Report form design

(2)

clip_image006

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;

using System.IO;

namespace emp

{

public partial class reportform : Form

{

public reportform(string company_name)

{

InitializeComponent();

showreport(company_name);

}

private void textBox1_TextChanged(object sender, EventArgs e)

{

}

private void reportform_Load(object sender, EventArgs e)

{

}

void showreport(string company_name)

{

try

{

conn ob = new conn();

SqlConnection obcon = new SqlConnection(ob.strconn);

SqlDataAdapter da = new SqlDataAdapter(“select * from works where company_name=@company_name “, obcon);

da.SelectCommand.Parameters.Add(“@company_name”, SqlDbType.VarChar, 50).Value = company_name;

DataSet ds=new DataSet ();

da.Fill (ds ,”emp”);

workreport rpt = new workreport();

rpt.SetDataSource(ds);

crystalReportViewer1 .ReportSource =rpt ;

}

catch

{ }

}

private static void NewMethod(DataSet ds, reportform rpt)

{

rpt.setdatasource(ds);

}

private void setdatasource(DataSet ds)

{

throw new NotImplementedException();

}

private void butshowreport_Click(object sender, EventArgs e)

{

showreport(Convert.ToString(txtbank_name.Text));

}

2(A)

create database bank

create table branch

(

branch_name varchar(50),

branch_city varchar(50),

asset int

)

create table customer

(

customer_name varchar(50),

customer_city varchar (50),

customer_city vrchar(50)

)

2(B)

Find the customers who have an account but no loan

(select distinct customer_name

from depositor)

except

(select customer_name

from borrower)

2(C)

Delete all loans with loan amounts between $13000 and $20000

Delete from loan

Where amount between 13000 and 20000

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s