Hello again guys,

I am little bit stuck in this situation and searched everywhere in google
but i did'nt find what actually i want..

a problem with autonumber in access database. i have created a database with 4 columns .. deleted primary key slip, cname, nic... the slip column is autonumber (not primary key).
heres my code and the error..

i want that when i enter slip number in textbox it searchs the slip no in the database
of slip column.. but i dont know whats the problem here.

and please tell me what is difference between oledbdatadapter and olebdcommand and oldbcommandreader.

ERROR:
{"Data type mismatch in criteria expression."}

Code:

long cno = Convert.ToInt64(textBox3.text);
  OleDbConnection connect = new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; data source = customers.mdb");
  OleDbDataAdapter adapter = new OleDbDataAdapter("Select * from Customer where Slip='" + cno + "'", this.connect);
 OleDbCommand read= new OleDbCommand("Select * from Customer where Slip='" + cno + "'", this.connect);

  this.connect.Open();
  object existentry = read.ExecuteScalar();
  if (existentry == null)
      {
        MessageBox.Show("Slip number not found.");
        return;
      }
   else
      {
        // blah blah code,
      }
this.Close();

ohhhhhh i am so sorry for this thread
i got what was the error .. please close this thread
well the error was
'" + cno + "'"
' ' means character while my autonumber contains integer
sorry. and thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.