| | |
Update from Asp.net to Sql server db
Please support our ASP.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
•
•
Join Date: Jun 2009
Posts: 14
Reputation:
Solved Threads: 0
...hope some body can help me resolve the problem....where i have to update a particular data ,
the datas are retreived from the db using a dropdownlist,selected data are updated inside a textbox...........
.....where there are constraints set by validators
for space and !^#$%&*^----charaecters:
My problm is data is not updated,please help me
Code
Asp.net C#---Sql server db)
..please suggest a soln..........
ICHU
the datas are retreived from the db using a dropdownlist,selected data are updated inside a textbox...........
.....where there are constraints set by validators
for space and !^#$%&*^----charaecters:
My problm is data is not updated,please help me
Code
Asp.net C#---Sql server db) c# Syntax (Toggle Plain Text)
private void btedit_Click(object sender, System.EventArgs e) { LabErr.Text=""; if(Page.IsValid==true) { SqlConnection con1=new SqlConnection(@"Server=sqloledb.1;User ID=sa;password=;Data Source=IRID_BDC1;Initial Catalog=newbie"); con1.Open(); SqlCommand cmd=new SqlCommand("Update Loc_mast Set Loc =('"+ txtrnme.Text+"') Where Loc =('"+ Droploc.SelectedItem.Text+"')",con1); cmd.ExecuteNonQuery(); } else { //txtrnme.Text=""; LabErr.Text="Please try Again"; }
..please suggest a soln..........
ICHU
Last edited by peter_budo; Jun 19th, 2009 at 4:22 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Change your query to be set to a string and break the debugger in there. Your drop down list might have an empty string value which would cause the update to not work. You are also not closing your SQL connection and you will run the connection pool out of available connections if your site has many users.
Try something like that and see if you get an exception. That should get you pointed in the right direction.
c# Syntax (Toggle Plain Text)
private void btedit_Click(object sender, System.EventArgs e) { LabErr.Text=string.Empty; if(Page.IsValid) { using (SqlConnection con1=new SqlConnection(@"Server=sqloledb.1;User ID=sa;password=;Data Source=IRID_BDC1;Initial Catalog=newbie")) { con1.Open(); string query = "Update Loc_mast Set Loc =('"+ txtrnme.Text+"') Where Loc =('"+ Droploc.SelectedItem.Text+"')"; if (string.IsNullOrEmpty(Droploc.SelectedItem.Text)) throw new Exception(); int iTest = Convert.ToInt32(Droploc.SelectedItem.Text); using (SqlCommand cmd=new SqlCommand(query,con1)) { cmd.ExecuteNonQuery(); } con1.Close(); } } else { //txtrnme.Text=""; LabErr.Text="Please try Again"; } }
Try something like that and see if you get an exception. That should get you pointed in the right direction.
•
•
Join Date: Dec 2007
Posts: 200
Reputation:
Solved Threads: 11
add a watch in the values at this point
ASP.NET Syntax (Toggle Plain Text)
SqlCommand cmd=new SqlCommand("Update Loc_mast Set Loc =('"+ txtrnme.Text+"') Where Loc =('"+ Droploc.SelectedItem.Text+"')",con1);
Could you please post the table structure of Loc_mast?
MARK AS SOLVED if its help you.
REGARDS
MCTS - Shawpnendu bikash maloroy
http://shawpnendu.blogspot.com
REGARDS
MCTS - Shawpnendu bikash maloroy
http://shawpnendu.blogspot.com
Use Slno for update operation rather than loc_no. Where clause shoud be
When you bind text properties of dropdown list must bind also Value properties by Slno.
Where Slno =('"+ Droploc.SelectedItem.Value+"')",con1) When you bind text properties of dropdown list must bind also Value properties by Slno.
MARK AS SOLVED if its help you.
REGARDS
MCTS - Shawpnendu bikash maloroy
http://shawpnendu.blogspot.com
REGARDS
MCTS - Shawpnendu bikash maloroy
http://shawpnendu.blogspot.com
Please post your bind code & the qurey that you use to update.
MARK AS SOLVED if its help you.
REGARDS
MCTS - Shawpnendu bikash maloroy
http://shawpnendu.blogspot.com
REGARDS
MCTS - Shawpnendu bikash maloroy
http://shawpnendu.blogspot.com
![]() |
Similar Threads
- Senior C#.Net Developer - Oxfordshire - ASP. Net, VB / Net - SQL Server (Web Development Job Offers)
- ASP.NET/SQL Developer/Programmer (Web Development Job Offers)
- ASP.NET SQL Server Setup Wizard: Failure (ASP.NET)
- Senior C#.Net Software Engineer - Oxfordshire - ASP. Net / SQL Server (Web Development Job Offers)
- ASP.NET & SQL Server 05 developer needed (Web Development Job Offers)
- ASP.Net perm full time programmer wanted (Web Development Job Offers)
- Software Engineer (.NET , SQL) (Software Development Job Offers)
- dreamweaver/ asp.net /sql server help needed please!!! (ASP.NET)
Other Threads in the ASP.NET Forum
| Thread Tools | Search this Thread |
.net 2.0 3.5 activexcontrol advice ajax alltypeofvideos asp asp.net bc30451 beginner bottomasp.net browser businesslogiclayer c# cac checkbox class commonfunctions confirmationcodegeneration contenttype countryselector css dataaccesslayer database datagrid datagridview datagridviewcheckbox deployment development dgv dropdownlist dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash flv formatdecimal forms formview gridview gudi iframe iis javascript jquery listbox menu microsoft mouse mssql multistepregistration nameisnotdeclared news objects opera panelmasterpagebuttoncontrols problem redirect registration relationaldatabases reportemail rotatepage schoolproject security serializesmo.table sessionvariables silverlight smartcard smoobjects software sql sql-server sqlserver2005 ssl textbox tracking treeview unauthorized validatedate validation vb.net video videos virtualdirectory vista visualstudio web webapplications webarchitecture webdevelopemnt webdevelopment webprogramming webservice youareanotmemberofthedebuggerusers







..Still not working