Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Whya the datas are not updating by this coding given below ...no any error message is giving but data are not updating.

my cs code is given below

C#
void submit(Object s, EventArgs e)
{
    con.Open();
    if ((File1.PostedFile != null) && (File1.PostedFile.ContentLength > 0))
    {
        fn = System.IO.Path.GetFileName(File1.PostedFile.FileName);
        fn = txtName.Text.Trim() + fn;
        SaveLocation = Server.MapPath("~/Upload/" + fn);
        txtPhoto.Text = SaveLocation;
    }
    else
    {
        string v = Request.QueryString["value1"];
        ds = new DataSet();
        string sql = "select photo FROM joining where refno='" + v + "' ";
        da = new OleDbDataAdapter(sql, con);
        da.Fill(ds, "joining");
        DataRow dRow = ds.Tables["joining"].Rows[0];
        txtPhoto.Text = dRow["photo"].ToString();
    }
    com = con.CreateCommand();
    if (con != null)
    {
        com.CommandText = "UPDATE joining SET aname = '" + txtName.Text.Trim() + "',fathname='" + txtFather.Text.Trim() + "',dob='" + txtDOB.Text.Trim() + "',pob='" + txtPOB.Text.Trim() + "',add1='" + txtAdd.Value + "',mob='" + txtMob.Text.Trim() + "',city='" + txtCity.Text.Trim() + "',state='" + txtState.Text.Trim() + "',pcode='" + txtPCode.Text.Trim() + "',panno='" + txtPAN.Text.Trim() + "',nominee='" + txtNominee.Text.Trim() + "',relation='" + txtRelation.Text.Trim() + "',photo='" + txtPhoto.Text.Trim() + "',bank='" + txtBank.Text.Trim() + "',branch='" + txtBranch.Text.Trim() + "',account='" + txtAccount.Text.Trim() + "',acctype='" + ddAccType.SelectedItem.Text + "',intby='" + txtIntro.Text.Trim() + "',codno='" + txtCodno.Text.Trim() + "',agent='" + txtACode.Text.Trim() + "',point='" + txtPoints.Text.Trim() + "' where refno='" + txtRefNo.Text.Trim() + "'";
        try
        {
            int count = 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
Updated 9-Feb-12 23:16pm
v2
Comments
lukeer 10-Feb-12 5:16am    
Added <pre> tag
Janardan Pandey 10-Feb-12 5:18am    
I dont now where it is added?
Janardan Pandey 10-Feb-12 5:36am    
records are available in my database table joining.
Searching and Deliting queries are working but only UPDATE is not working.
Ramanujam Shankar 10-Feb-12 5:19am    
I think records not available in your Joining Table. check it from your database.
Janardan Pandey 10-Feb-12 5:36am    
records are available in my database table joining.
Searching and Deliting queries are working but only UPDATE is not working.

The UPDATE command will not generate errors if it cannot find any rows to update.

Get the concatenated string from your Debug windows and run it in the database directly. You database will tell you how many rows (if any) were updated. Your JOINS or WHERE clause might be the problem.
 
Share this answer
 
Comments
Janardan Pandey 10-Feb-12 5:38am    
how to do it in ms access database directly ?
Hi,

There in Joining table, records should be there first. check again.
 
Share this answer
 
Comments
Janardan Pandey 10-Feb-12 5:41am    
I checked records are there.

Search and delete is working but only update is not working.When i change some information in my web page in local host and click for update to update button.But old records send only not new records taken by it.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900