update query in ms-access doesn't working

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • abhilashcashok@gmail.com

    update query in ms-access doesn't working


    hi guys, my prblem is that I cannot update sql query against MS ACCESS
    using C#. Everytime wen i do so, i got an exception (at runtime) as
    'UPDATE syntax not correct'. I don find any error in my 'update'
    syntax.

    I can successfully run other dbase operations like insertion, deletion
    & all.; except Updation.

    But, i can successfully run the same update query in the 'sql query
    tab' of MS ACCESS, and is executed successfully.

    I'm using VS.NET 2005 & MS ACCESS 2003.

    please help me...its urgent.

    i'm including the code below :

    *************** *************** *************** *************** *****

    string provider = "Provider = Microsoft.Jet.O leDb.4.0; Data Source =
    db1.mdb;";
    string sql = "update Table1 set Password = 'modify' where ID =
    'abhi'";

    try
    {
    OleDbConnection oc = new OleDbConnection (provider);
    OleDbCommand od = new OleDbCommand(sq l, oc);
    oc.Open();

    od.ExecuteNonQu ery();

    oc.Close();
    }
    catch (Exception exp)
    {
    return exp.Message;
    }

    *************** *************** *************** *************** *****

    My table contains two field : "ID" & "Password", both are of String
    type.

    *************** *************** *************** *************** *****

    thanks in advance
  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: update query in ms-access doesn't working

    I'm not sure, but perhaps it is the quotes in the string (mabye it is
    looking for a double-quote)?

    I doubt that your string is a constant like that, but rather, a string
    that you concatenate together. In this case, you should use a parameterized
    query, and let the provider handle the parameter formatting issues for you.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    <abhilashcashok @gmail.comwrote in message
    news:61bf88ff-6ca2-452e-bc40-b42190024a6f@a3 9g2000pre.googl egroups.com...
    >
    hi guys, my prblem is that I cannot update sql query against MS ACCESS
    using C#. Everytime wen i do so, i got an exception (at runtime) as
    'UPDATE syntax not correct'. I don find any error in my 'update'
    syntax.
    >
    I can successfully run other dbase operations like insertion, deletion
    & all.; except Updation.
    >
    But, i can successfully run the same update query in the 'sql query
    tab' of MS ACCESS, and is executed successfully.
    >
    I'm using VS.NET 2005 & MS ACCESS 2003.
    >
    please help me...its urgent.
    >
    i'm including the code below :
    >
    *************** *************** *************** *************** *****
    >
    string provider = "Provider = Microsoft.Jet.O leDb.4.0; Data Source =
    db1.mdb;";
    string sql = "update Table1 set Password = 'modify' where ID =
    'abhi'";
    >
    try
    {
    OleDbConnection oc = new OleDbConnection (provider);
    OleDbCommand od = new OleDbCommand(sq l, oc);
    oc.Open();
    >
    od.ExecuteNonQu ery();
    >
    oc.Close();
    }
    catch (Exception exp)
    {
    return exp.Message;
    }
    >
    *************** *************** *************** *************** *****
    >
    My table contains two field : "ID" & "Password", both are of String
    type.
    >
    *************** *************** *************** *************** *****
    >
    thanks in advance

    Comment

    • =?ISO-8859-1?Q?Arne_Vajh=F8j?=

      #3
      Re: update query in ms-access doesn't working

      abhilashcashok@ gmail.com wrote:
      hi guys, my prblem is that I cannot update sql query against MS ACCESS
      using C#. Everytime wen i do so, i got an exception (at runtime) as
      'UPDATE syntax not correct'. I don find any error in my 'update'
      syntax.
      >
      I can successfully run other dbase operations like insertion, deletion
      & all.; except Updation.
      >
      But, i can successfully run the same update query in the 'sql query
      tab' of MS ACCESS, and is executed successfully.
      string provider = "Provider = Microsoft.Jet.O leDb.4.0; Data Source =
      db1.mdb;";
      string sql = "update Table1 set Password = 'modify' where ID =
      'abhi'";
      Maybe password is a reserved word.

      Try:

      string sql = "update Table1 set [Password] = 'modify' where ID = 'abhi'";

      Arne

      Comment

      • christery@gmail.com

        #4
        Re: update query in ms-access doesn't working

        On 24 Nov, 16:57, Arne Vajhøj <a...@vajhoej.d kwrote:
        abhilashcas...@ gmail.com wrote:
        hi guys, my prblem is that I cannot update sql query against MS ACCESS
        using C#. Everytime wen i do so, i got an exception (at runtime) as
        'UPDATE syntax not correct'. I don find any error in my 'update'
        syntax.
        >
        I can successfully run other dbase operations like insertion, deletion
        & all.; except Updation.
        >
        But, i can successfully run the same update query in the 'sql query
        tab' of MS ACCESS, and is executed successfully.
        string provider = "Provider = Microsoft.Jet.O leDb.4.0; Data Source =
        db1.mdb;";
        string sql = "update Table1 set Password = 'modify' where ID =
        'abhi'";
        >
        Maybe password is a reserved word.
        >
        Try:
        >
        string sql = "update Table1 set [Password] = 'modify' where ID = 'abhi'";
        >
        Arne
        check if an @ might help... donno why but test string sql = @"update
        Table1 set Password = 'modify' where ID = 'abhi'";
        dont think password is reserved, but new to c#

        //CY

        Comment

        • =?ISO-8859-1?Q?Arne_Vajh=F8j?=

          #5
          Re: update query in ms-access doesn't working

          christery@gmail .com wrote:
          On 24 Nov, 16:57, Arne Vajhøj <a...@vajhoej.d kwrote:
          >abhilashcas... @gmail.com wrote:
          >>hi guys, my prblem is that I cannot update sql query against MS ACCESS
          >>using C#. Everytime wen i do so, i got an exception (at runtime) as
          >>'UPDATE syntax not correct'. I don find any error in my 'update'
          >>syntax.
          >>I can successfully run other dbase operations like insertion, deletion
          >>& all.; except Updation.
          >>But, i can successfully run the same update query in the 'sql query
          >>tab' of MS ACCESS, and is executed successfully.
          >>string provider = "Provider = Microsoft.Jet.O leDb.4.0; Data Source =
          >>db1.mdb;";
          >>string sql = "update Table1 set Password = 'modify' where ID =
          >>'abhi'";
          >Maybe password is a reserved word.
          >>
          >Try:
          >>
          >string sql = "update Table1 set [Password] = 'modify' where ID = 'abhi'";
          >
          check if an @ might help... donno why but test string sql = @"update
          Table1 set Password = 'modify' where ID = 'abhi'";
          The @ should not have any impact here - no \ characters.
          dont think password is reserved
          http://support.microsoft.com/kb/248738 claims it is.

          Arne

          Comment

          • christery@gmail.com

            #6
            Re: update query in ms-access doesn't working

            >
            dont think password is reserved
            >
            http://support.microsoft.com/kb/248738claims it is.
            >
            Arne- Dölj citerad text -
            >
            - Visa citerad text -
            I stand corrected, was thinking just C#, not access

            //CY

            Comment

            Working...