Posts

Showing posts with the label insert

Insert data in AutoNumber DataType (Access Database).

Hi to all. Normally we insert data in table.but when we need some unique identity we use primary key and make  AutoNumber datatype in access database. so when we insert data in database not add column in query of insert. Like table name is Test and columns are Id=>AutoNumber,Name=>Text Query for insert is ="Insert into Test (Name) Values ('TestName')" Hear we not mention Id because Id is AutoNumber. It automatically set last id increment 1.and if we want the inserted id in database after insert query make one code " Select @@Identity "; to execute.         public int InsertData(string sQuary)         {             try             {                 //for get last inserted id                 string sQryIdentity = "Select @@Identity";             ...

CRUD Operations in win form application with access database

Hi to all, In first post we connect with access database now in this post we make operations in database. First we create one method that help to execute sql query in database. public bool Executquary (string sQuary)         {             try             { //check connection                 if (dbConnection.State != ConnectionState.Open)                 {                     dbConnection.Open();                 } //create command                 OleDbCommand cmd = new OleDbCommand(sQuary);                 cmd.Connection = dbConnection;                 try                 { /...