Professional Documents
Culture Documents
Connectivity: Using Using Using Using Using Using Using Using Using
Connectivity: Using Using Using Using Using Using Using Using Using
Connectivity: Using Using Using Using Using Using Using Using Using
SqlDataAdapter sda = new SqlDataAdapter("select * from lib1", con); String sql = String.Format("delete from lib1 where title='{0}'", title); SqlCommand cmd = new SqlCommand(sql, con); int rowset = cmd.ExecuteNonQuery(); con.Close(); } [WebMethod] public void insert(int bookid, string bookname, string author, string title) { SqlConnection con = new SqlConnection("Data Source=(local);integrated security=SSPI;initial catalog=Northwind"); con.Open(); SqlDataAdapter sda = new SqlDataAdapter("select * from lib1", con); String sql = String.Format("insert into lib1 values({0},'{1}','{2}','{3}')", bookid, bookname, author, title); SqlCommand command = new SqlCommand(sql, con); int rowset = command.ExecuteNonQuery(); con.Close(); } [WebMethod] public DataSet find(int i) { SqlConnection con = new SqlConnection("Data Source=(local);integrated security=SSPI;initial catalog=Northwind"); SqlDataAdapter sda = new SqlDataAdapter("select * from lib1 where bookid='" + i + "'", con); DataSet ds= new DataSet(); con.Open(); sda.Fill(ds, "lib1"); return ds; } [WebMethod] public DataSet view() { SqlConnection con = new SqlConnection("Data Source=(local);integrated security=SSPI;initial catalog=Northwind"); SqlDataAdapter sda = new SqlDataAdapter("select * from lib1", con); DataSet ds = new DataSet(); con.Open(); sda.Fill(ds, "lib1"); return ds; } }
{ DataSet ds = ss.view(); foreach (DataRow r in ds.Tables["lib1"].Rows) { TextBox3.Text = r[0].ToString(); TextBox4.Text = r[1].ToString(); TextBox5.Text = r[2].ToString(); TextBox6.Text = r[3].ToString(); } } protected void Button5_Click(object sender, EventArgs e) { int i = Int32.Parse(TextBox3.Text); DataSet ds = ss.find(i); foreach (DataRow r in ds.Tables["lib1"].Rows) { TextBox3.Text = r[0].ToString(); TextBox4.Text = r[1].ToString(); TextBox5.Text = r[2].ToString(); TextBox6.Text = r[3].ToString(); } } }