Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Access and update a Staff table ) Write a program that views, inserts, and updat

ID: 3861972 • Letter: A

Question

Access and update a Staff table) Write a program that views, inserts, and
updates staff information stored in a database, as shown in Figure 32.27a. The
View button displays a record with a specified ID. The Insert button inserts a new
record. The Update button updates the record for the specified ID. The Staff
table is created as follows:
create table Staff (
id char(9) not null,
lastName varchar(15),
firstName varchar(15),
mi char(1),
address varchar(20),
city varchar(20),
state char(2),
telephone char(10),
email varchar(40),
primary key (id)
);

Explanation / Answer

Onces you can create some database in database table we can create a columns,delete a columns,update a coulmns in number of is their so we write the quries

first u can create a Database

Create database databasename

Viewing program

Select * from Table tablename

so we can some program is their

public void viewdata()

{
connection();
query = "studentEntryView";
SqlCommand com = new SqlCommand(query, con);
com.CommandType = CommandType.StoredProcedure;
com.Parameters.AddWithValue("@Action", HiddenField2.Value).ToString();
DataSet ds =new DataSet();
SqlDataAdapter da = new SqlDataAdapter(com);
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}

INSERT VALUES

INSERT INTO Student VALUES ( ‘Kitty’,1213, ‘18-06-1991’ , ‘27-M,Jyoti enclave, Hyderabad’,’F’,3);

DELETE COMMAND

DELETE FROM Student
WHERE Br_No IN ( SELECT BNo
FROM Branch
WHERE BName =”Electronics”);

UPDATE

UPDATE Resource
SET No_of_resources = No_of_Resources + 1
WHERE CId IN ( SELECT CId

FROM Course

WHERE CName = ‘Operating Systems’);

VIEWS

CREATE VIEW Resources1
AS SELECT *
FROM Student, Branch AS B, Course AS C
WHERE Br_No = B.BNo