TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Kamala Veni
NA
65
21.5k
C#, Asp.net
Mar 2 2016 2:37 AM
Hi
Am having Multiple Text box in the form after entering details having a sepreate save button,i haved the data,bt while clicking individual save button have to save and all textbox should clean ..
hw i can do dat?
protected void btsn1_Click(object sender, EventArgs e)
{
SqlConnection cnn = new SqlConnection();
cnn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["cppschConnectionString"].ConnectionString; cnn.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "select * from tbl_sch111";
cmd.Connection = cnn;
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataSet ds = new DataSet();
da.Fill(ds, "tbl_sch111");
SqlCommandBuilder cb = new SqlCommandBuilder(da);
DataRow drow = ds.Tables["tbl_sch111"].NewRow();
drow["Date"] = lb.Text;
drow["Time"] = lbb.Text;
drow["Day"] = lbd.Text;
drow["blk_1"] = txtbl1.Text;
drow["blk_2"] = txtbl2.Text;
drow["blk_3"] = txtbl3.Text;
drow["blk_4"] = txtbl4.Text;
drow["blk_5"] = txtbl5.Text;
drow["blk_6"] = txtbl6.Text;
drow["blk_7"] = txtbl7.Text;
drow["blk_8"] = txtbl8.Text;
drow["blk_9"] = txtbl9.Text;
drow["blk_10"] = txtbl10.Text;
ds.Tables["tbl_sch111"].Rows.Add(drow);
da.Update(ds, "tbl_sch111");
ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "alert('Data Insert Successfully...');", true);
}
protected void bts2_Click(object sender, EventArgs e)
{
SqlConnection cnn = new SqlConnection();
cnn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["cppschConnectionString"].ConnectionString; cnn.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "select * from tbl_sch111";
cmd.Connection = cnn;
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataSet ds = new DataSet();
da.Fill(ds, "tbl_sch111");
SqlCommandBuilder cb = new SqlCommandBuilder(da);
DataRow drow = ds.Tables["tbl_sch111"].NewRow();
drow["Day"] = l2.Text;
drow["Time"] = l.Text;
drow["Date"] = l3.Text;
drow["blk_1"] = TextBox1.Text;
drow["blk_2"] = TextBox2.Text;
drow["blk_3"] = TextBox3.Text;
drow["blk_4"] = TextBox4.Text;
drow["blk_5"] = TextBox5.Text;
drow["blk_6"] = TextBox6.Text;
drow["blk_7"] = TextBox7.Text;
drow["blk_8"] = TextBox8.Text;
drow["blk_9"] = TextBox9.Text;
drow["blk_10"] = TextBox10.Text;
ds.Tables["tbl_sch111"].Rows.Add(drow);
da.Update(ds, "tbl_sch111");
ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "alert('Data Insert Successfully...');", true);
//Response.Redirect("Upsch.aspx");
}
Reply
Answers (
3
)
attaching debugger
[Help] I need to know how to use insert ,update ,delete