C#

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pankajgiri31
    New Member
    • Oct 2008
    • 1

    C#

    I have a problem when i want to read data from Access table using this code:-


    public void insert()
    {
    MyCommand.Comma ndText = "Select UserName from User_Login Where ID=' 1 ';
    MyCommand.Comma ndType = CommandType.Tex t;
    MyCommand.Conne ction = MyConnection;

    MyAdapter.Selec tCommand = MyCommand;
    MyAdapter.Fill( MyTable);

    GridView1.DataS ource = MyTable.Default View;
    GridView1.DataB ind();

    MyAdapter.Dispo se();
    MyCommand.Dispo se();
    MyConnection.Di spose();

    }


    but in run time i found one error...
    Data type mismatch in criteria expression.

    pls solve my problem thanks
  • Shashi Sadasivan
    Recognized Expert Top Contributor
    • Aug 2007
    • 1435

    #2
    Try the following:

    Code:
    MyCommand.CommandText = "Select UserName from User_Login Where ID=\' 1 \'";
    however is the ID field of type text or integer? (it seems that you have set ID as text based field)

    Comment

    Working...