| | |
Update from Asp.net to Sql server db
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
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: 205
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
Views: 1426 | Replies: 12
| Thread Tools | Search this Thread |
Tag cloud for ASP.NET
.net 2.0 activexcontrol advice ajax alltypeofvideos anathor application asp asp.net bc30451 bottomasp.net browser button c# checkbox click commonfunctions confirmationcodegeneration css dataaccesslayer database datagridview datagridviewcheckbox datalist deadlock development dgv dropdownlist dynamically edit editing expose feedback fill flash form formatdecimal formview google grid gridview iframe iis javascript list listbox login microsoft migration mono mouse mssql multistepregistration news numerical object objects opera panelmasterpagebuttoncontrols parent problem project radio registration reportemail richtextbox rotatepage rows save schoolproject search security session silverlight smartcard smoobjects software sql-server sqlserver2005 suse textbox tracking unauthorized update validation vb.net video videos view virtualdirectory vista visualstudio web webapplications webdevelopemnt webprogramming webservice xsl youareanotmemberofthedebuggerusers







..Still not working