Sulieman Alkatib

Sulieman Alkatib

  • NA
  • 56
  • 4.7k

increment ID automatically by adding +1

Apr 29 2017 7:35 AM
I'm developing a simple application to insert values to ms access database but I need to make event ID as automated field by get maximum value from the column and add +1 to insert the new value
 
 
  1. OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\zoom\Desktop\TRAVIL IN OMAN PROJECT - Copy\WebApplication1\WebApplication1\App_Data\travilinoman.MDB.mdb");  
  2.        con.Open();  
  3.        OleDbCommand cmd = new OleDbCommand("select MAX(ID)+1 from event", con);  
  4.        OleDbDataReader dr = cmd.ExecuteReader();  
  5.        TextBox1.Text = dr.ToString();  
  6.            con.Close();  
 the textboxis showing this result : System.Data.OleDb.OleDbDataReader
 
how can I convertit to the acctual value (int) ??? 

Answers (5)