Results 1 to 3 of 3

Thread: update records in the Ms Access

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    153

    update records in the Ms Access

    hi to all,
    i have created one table in Ms Access is


    string query="create table testtable1(Name Text(50),age Number,email Text(50),phoneno Text(50),sysdate DateTime)";
    clsGlobalFields.oledbcon = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+ txtdbsName.Text +";persist security Info=false");
    clsGlobalFields.oledbcon.Open();
    clsGlobalFields.oledbcmd = new OleDbCommand(query, clsGlobalFields.oledbcon);
    clsGlobalFields.oledbcmd.ExecuteNonQuery();
    clsGlobalFields.oledbcon.Close();



    when i am inserting the value in that table,it fine. But when i am updating the value in that table it given the error"Type mismatch".


    Actually i have used two update queries

    one update query work fine. the query is

    string query="update testtable1 set Name = 'mary' , age = 20, email = 'kfolklklklklkll', phoneno = 3455566567, sysdate = '3/21/2007 12:00:00 AM' where Name = 'nithi' AND age = 20 AND email = 'kfolklklklklkll' AND phoneno = 234455666";
    clsGlobalFields.oledbcon = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + txtdbsName.Text + ";persist security Info=false");
    clsGlobalFields.oledbcon.Open();
    clsGlobalFields.oledbcmd = new OleDbCommand(query, clsGlobalFields.oledbcon);
    clsGlobalFields.oledbcmd.ExecuteNonQuery();
    clsGlobalFields.oledbcon.Close();


    this query is working fine.


    But when i am include the sysdate in the where condition it will given the error "Type mismatch". the query is


    string query="update testtable1 set Name = 'mary' , age = 20, email = 'kfolklklklklkll', phoneno = 3455566567, sysdate = '3/21/2007 12:00:00 AM' where Name = 'nithi' AND age = 20 AND email = 'kfolklklklklkll' AND phoneno = 234455666" AND sysdate = '3/21/2007 12:00:00 AM';
    clsGlobalFields.oledbcon = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + txtdbsName.Text + ";persist security Info=false");
    clsGlobalFields.oledbcon.Open();
    clsGlobalFields.oledbcmd = new OleDbCommand(query, clsGlobalFields.oledbcon);
    clsGlobalFields.oledbcmd.ExecuteNonQuery();
    clsGlobalFields.oledbcon.Close();



    Plz somebody help me. i am trying the solution for that . plz sombody help me

    thank u

    with thanks and regards
    MMary

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: update records in the Ms Access

    Enclose your date/time literals in # symbols. Single quotes are for text. Presumably the system is implicitly converting the text to a date/time when you're setting a field but it's refusing to compare text to existing date/time values.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    153

    Re: update records in the Ms Access

    Thank u very much for ur kind reply.

    Now, my query is working . thank u . thank u very much

    with thanks and regards
    MMary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width