Click here to Skip to main content
12,945,066 members (69,018 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
Why the data are not updating in table.
My cs coading is given below
void submit(Object s, EventArgs e)
{
con.Open();
com=con.CreateCommand();
if(con!=null)
{
com.CommandText="UPDATE joining SET aname = '" + txtName.Text.Trim() + "',fathname='" +   txtFather.Text.Trim()+ "' where refno='" + txtRefNo.Text.Trim() + "'";
try{
com.ExecuteNonQuery();
System.Web.UI.WebControls.Label lbl1=new System.Web.UI.WebControls.Label();
lbl1.ForeColor=System.Drawing.Color.Yellow;
lbl1.BackColor=System.Drawing.Color.Blue;
lbl1.Text="Your record UPDATED sucessfully";
ph1.Controls.Add(lbl1);
}
catch(Exception ex)
{
Response.Write(ex.Message);
}}
con.Close();
}
Posted 20-Jan-12 21:39pm
Updated 20-Jan-12 21:43pm
ambarishtv10.5K
v2

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

There are a numbers of problems with you code.

First _DO_ not build SQL statements like you do. Use SqlParamenter[^], but why?
See http://www.codinghorror.com/blog/2005/04/give-me-parameterized-sql-or-give-me-death.html[^]

But lets say that you SQL update statement is correct. Then it all depends on you WHERE clause.
Is there a record you table 'joining' that has 'refno' matching the one applied?

Are there any exceptions, what does 'com.ExecuteNonQuery()' returns ?
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 4,781
CHill60 3,135
Maciej Los 2,443
Jochen Arndt 1,910
ppolymorphe 1,765


Advertise | Privacy | Mobile
Web01 | 2.8.170518.1 | Last Updated 21 Jan 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100