I am sorry not to answer so long, it is because my modem was out of order.
I have simple controls on aspx page viz. textbox to accept values from user and a button. On button's click event I want to update those many records that have been entered by user.
first get separated by comma which record are going to update.
when button click
upadte emptbl set emp_shift='day shift' where emp_id in(put collection of id u want)
A.Venkatesan
Microsoft Certified Professional
Please mark the replies as answers if they help or unmark if not.
If you have any feedback about my replies, please contact venkatmca008@gmail.com
ok, I will try this code. But where is the stored procedure definition. and why you have used <xml><table> etc. I am not storing the whole xml table. I have a table containg only 3 fields. Id, Name, Value. Where Id is for identifying every setting differentely.
Name is the name of setting e.g. SiteName, AreCommentsAllowed, NoOfPosts etc. and Value is the actual value of the setting which defines it. e.g.SiteName = abcd.com, AreCommentsAllowed = No, NoOfPosts = 7 etc....
rajanireddy
Member
362 Points
161 Posts
Re: Update multiple rows at once
Feb 01, 2012 03:50 AM|LINK
StringBuilder sbXMLRights
;sbXMLRights
=new StringBuilder
();sbXMLRights
.Append("<XML><TABLE>");DataTable dt
= AddVoucher;sbXMLRights
.Append("<ROW>");sbXMLRights
.Append("<Id>" + textbox1.text.ToString() + "</Id>");sbXMLRights
.Append("<Name>"+ dropdown1.SelectedItem.Text.ToString() + "</Name>");sbXMLRights
.Append("<value>"+ dropdown1.SelectedItem.Text.ToString() + "</value>");sbXMLRights
.Append("</ROW>");sbXMLRights
.Append("</XML></TABLE>");SqlParameter[] pars
= new SqlParameter[1];SqlConnection con
= dbconnect.GetSqlConnection();SqlCommand cmd
= new SqlCommand("SP_SITEBOOKTRANSFER", con);cmd
.CommandType = CommandType.StoredProcedure;cmd
.Connection = con;cmd
.Parameters.AddWithValue("@XML_RIGHTS",XML_RIGHTS);string
str = Convert.ToString(cmd.ExecuteScalar());con
.Close();sophia_asp
Member
521 Points
469 Posts
Re: Update multiple rows at once
Feb 18, 2012 07:47 AM|LINK
Hi, rajini,
I am sorry not to answer so long, it is because my modem was out of order.
I have simple controls on aspx page viz. textbox to accept values from user and a button. On button's click event I want to update those many records that have been entered by user.
Thanks....
venkatmca008
Participant
1810 Points
341 Posts
Re: Update multiple rows at once
Feb 18, 2012 07:51 AM|LINK
Hi....you can achive...this.
first get separated by comma which record are going to update.
when button click
upadte emptbl set emp_shift='day shift' where emp_id in(put collection of id u want)
Microsoft Certified Professional
Please mark the replies as answers if they help or unmark if not.
If you have any feedback about my replies, please contact venkatmca008@gmail.com
rajanireddy
Member
362 Points
161 Posts
Re: Update multiple rows at once
Feb 18, 2012 08:03 AM|LINK
Ok, I will send you code in half an hour.
sophia_asp
Member
521 Points
469 Posts
Re: Update multiple rows at once
Feb 19, 2012 07:49 AM|LINK
Hi Rajini,
I did not get any code.
Please help
Thanks
rajanireddy
Member
362 Points
161 Posts
Re: Update multiple rows at once
Feb 20, 2012 03:13 AM|LINK
Hi, on wwhat condition, the records have to get updated.
sophia_asp
Member
521 Points
469 Posts
Re: Update multiple rows at once
Feb 20, 2012 06:46 AM|LINK
Hi Rajani,
There is no condition, user changes values (or even does not change), but when he clicks update button then all input control's values
must be saved.
Thanks....
rajanireddy
Member
362 Points
161 Posts
Re: Update multiple rows at once
Feb 20, 2012 06:57 AM|LINK
StringBuilder sbXMLRights;
sbXMLRights=
new StringBuilder();
sbXMLRights.Append(
"<XML><TABLE>");
string value = txtDesignationName.Text;
string[] v = value.Split(',');
foreach (string s in v)
{
sbXMLRights.Append(
"<ROW>");
sbXMLRights.Append(
"<value>" + s + "</value>");
sbXMLRights.Append(
"</ROW>");
}
sbXMLRights.Append(
"</XML></TABLE>");
SqlParameter[] pars=
new SqlParameter[1];
SqlConnection con= dbconnect.GetSqlConnection();
SqlCommand cmd=
new SqlCommand("ProcedureName", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = con;
cmd.Parameters.AddWithValue(
"@XML_RIGHTS", sbXMLRights.ToString());
string str = Convert.ToString(cmd.ExecuteScalar());
con.Close();
rajanireddy
Member
362 Points
161 Posts
Re: Update multiple rows at once
Feb 20, 2012 06:59 AM|LINK
I have already sent the procedure.
If you still have any doubt, send your aspx page and table structure.
sophia_asp
Member
521 Points
469 Posts
Re: Update multiple rows at once
Feb 20, 2012 07:04 AM|LINK
ok, I will try this code. But where is the stored procedure definition. and why you have used <xml><table> etc. I am not storing the whole xml table. I have a table containg only 3 fields. Id, Name, Value. Where Id is for identifying every setting differentely. Name is the name of setting e.g. SiteName, AreCommentsAllowed, NoOfPosts etc. and Value is the actual value of the setting which defines it. e.g.SiteName = abcd.com, AreCommentsAllowed = No, NoOfPosts = 7 etc....
Thanks....