You must Sign In to post a response.
  • Category: ASP.NET

    Error occured while updating table

    try to update my table.but error occured like Incorrect syntax near '='. in executenonquery.fix it??

    msql.Open();
    string query = "upadate tbl_Admission set AdmissionNumber='" + txt_mod_Adnum.Text + "',Name='"+txt_mod_Name.Text+"',FatherName='"+txt_mod_Fathername.Text+"',Presentaddress='"+txt_mod_preaddress.InnerText+"',Permanentaddress='"+txt_mod_peraddress.InnerText+"',mobile='"+txt_mod_mobile.Text+"',dob='"+txt_mod_resnum.Text+"',resnumber='"+txt_mod_resnum.Text+"',gender='"+gen+"' where AdmissionNumber='"+txt_mod_Adnum.Text+"'";
    mcmd = new SqlCommand(query, msql);
    mcmd.Connection = msql;
    int count=mcmd.ExecuteNonQuery();
    if (count > 0)
    {
    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Record Updated Successfully')", true);
    }
    else
    {
    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Record not updated')", true);
    }
    msql.Close();
  • #767316
    There may be data issue. Just debug the code and check what value getting for the variable "query".
    Get the value at the time of debugging and try to execute it directly in the query analyser. You can easily identity the issue. If you you not able to identify just past the value which you are getting for "query". So that we can easily identify the issue.

    By Nathan
    Direction is important than speed

  • #767317
    thanks.. i found the error . upadate typed instead update.
    but again next error comes like
    Conversion failed when converting date and/or time from character string.
    i have a date type column

  • #767318
    It is clearly showing the issue in data of date time. Check all the date field whether are you sending correct date format.
    By Nathan
    Direction is important than speed

  • #767323
    Hi

    May be Date Format is incorrect so you can follow the date format this



    SELECT CONVERT(VARCHAR(20),GETDATE(),100)
    SELECT CONVERT(VARCHAR(20),GETDATE(),101)
    SELECT CONVERT(VARCHAR(20),GETDATE(),102)
    SELECT CONVERT(VARCHAR(20),GETDATE(),103)
    SELECT CONVERT(VARCHAR(20),GETDATE(),104)


    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #767340
    Hi,

    What data query returns ? copy the content which "query" returns and then execute the same in Microsoft SQL server and recheck the syntax, whether it gives proper syntaxing or not then modify the query and update the same in your application.

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/


Sign In to post your comments