数据没有更新也没有给出任何错误 [英] Data are not updating also not giving any error

查看:50
本文介绍了数据没有更新也没有给出任何错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么数据没有通过下面给出的这种编码进行更新...没有给出任何错误消息,但是数据没有更新.

我的CS代码在下面给出

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

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();
}

推荐答案

如果UPDATE命令找不到要更新的行,则不会生成错误.

从调试"窗口获取串联的字符串,然后直接在数据库中运行它.您的数据库将告诉您已更新了多少行(如果有).您的JOINS或WHERE子句可能是问题所在.
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.




在联接表中,记录应该首先存在.再次检查.
Hi,

There in Joining table, records should be there first. check again.


这篇关于数据没有更新也没有给出任何错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆