Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

i have my access database document already inserted, and i want to link the sear

ID: 3938354 • Letter: I

Question


i have my access database document already inserted, and i want to link the search, save , Delete buttons to it. so that i would be able to record to my database document and to delete from it and search from it . what codes do i need to write behind each of those buttons to make it work . and please be very detail.
note : i am using access database document (OLEDb) and if there is connection string tell me exactly where to find it .

fat View12ject Bild Debug Tern Fornit Tools Test Arabyse window Help Threuct 83161 Main Threed Senes mmediate Window Outpu Watch Asc me anything

Explanation / Answer

accessing ms acces database by using its drivers. jdbc odbc bridge driver is used to connect the database.

OLEDB also has more advantages than ODBC.

to establish a connection

OleDbConnection con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=yourdatabase.accdb");

or use below:

SqlConnection sqlConnection = new SqlConnection();
sqlConnection.ConnectionString = ConfigurationManager.ConnectionStrings["DBConnectionString"].ConnectionString.Trim();

try the below code to performing basic opeartion on access databse.

SqlConnection sqlConnection = new SqlConnection();
sqlConnection.ConnectionString = ConfigurationManager.ConnectionStrings["DBConnectionString"].ConnectionString.Trim();
SqlCommand sqlCommand = new SqlCommand();
{
sqlConnection.Open();
sqlCommand.CommandText = "Insert into Student (Name, Address, Phone) _values(" + "'"+txtName.Text +"'"+ "," + "'"+txtAddress.Text + "'"+", _
" + "'"+txtPhone.Text +"'"+ ")";//insert data into table
sqlCommand.Connection = sqlConnection;
sqlCommand.ExecuteNonQuery();

SqlDataAdapter sqlDataAdapter = new SqlDataAdapter("Select * from Student ", sqlConnection); //code for reading database
DataSet dataSet = new DataSet();
sqlDataAdapter.Fill(dataSet);

SqlDataAdapter sqlDataAdapter = new SqlDataAdapter("Select * from Student ", sqlConnection);//updating the database
DataSet dataSet = new DataSet();
sqlDataAdapter.Fill(dataSet);
SqlCommandBuilder sqlCom = new SqlCommandBuilder(sqlDataAdapter);
DataRow dataRow =dataSet.Tables[0].NewRow();
dataRow[0] = “Daniel”;
dataRow[1] = "michigan";
dataSet.Tables[0].Rows.Add(dataRow);
dataAdapter.Update(dataSet);

}

catch (Exception ex)
{
Response.Write(ex);
}
      
finally
{
sqlConnection.Close();
}