i have my access database document already inserted, and i want to link the sear
ID: 3937530 • 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)
fat View12ject Bild Debug Tern Fornit Tools Test Arabyse window Help Threuct 83161 Main Threed Senes mmediate Window Outpu Watch Asc me anythingExplanation / Answer
using System;
using System.Data;
using System.Data.OleDb;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1:Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string connectionString = null;
OleDbconnection connection;
OleDbDataAdapter oldbAdapter = new oleDbDataAdapter();
string sql = null;
connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Your mdb filename;";
connection = new OleDbConnection(connetionString);
sql = "delete from tblusers1 where UserID = 'user1'";
try
{
connection.Open();
oledbAdapter.DeleteCommand = connection.CreateCommand();
oledbAdapter.DeleteCommand.CommandText = sql;
oledbAdapter.DeleteCommand.ExecuteNonQuery();
MessageBox.Show("Row(s) Deleted !! ");
}
catch (Exception ex)
{
MessageBox.show(ex.ToString());
}
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.