i already have my access database document and i already upl
i already have my access database document and i already uploaded it in my visual studio compiler and i already created c# application forms with 3 buttons Save, Delete ,and Search, and a text box that i am going to type what i am going to search, and i also make a chart next to it for showing the summary report of my access database document . so basically what i want is to write the code in c# for each button to do its job for example whenever i save something or delete something in visual studio it gets saved directly to my access database document or or gets deleted from it so that when i go to my access database document it is deleted there .And for the chart , i want my summary report in my access database document to connect to the chart so that it shows the summary report on the chart.
here is my layout. and the buttons already created but they are not working because i dont know how to connect each button to function. and the chart should show the summary report that i have and i dont know how to connect it with it . please make it as detail as possible. Thanks
Solution
Answer :-
Steps :-
Step 1 ) First open visual studio and we can create one windows project .
Step 2) open App.config and write connection string.
<connectionStrings>
<add name=\"dbconnection\" connectionString=\"Data ource=servername;uid=exampleuserid;
Password=examplepassword;database=Hospital\" providerName=\"System.Data.SqlClient\" />
</connectionStrings>
Step 3) write c# code in your codebehind add this two name spaces.
using System.Data.SqlClient;
using System.Configuration;
Step 4) write c# code in your codebehind connectin string.
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings[\"dbconnection\"].ConnectionString);
Step 5) double click on save buttion and we can write c# code in codebehind .cs file.
private void save_Click(object sender, EventArgs e)
{
string s = \"insert into tablename values(\'\" + textboxid1.Text + \"\',\'\" + textboxid2.Text + \"\',\'\" + textboxid3.Text + \"\')\";
SqlCommand cmd = new SqlCommand(s, con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show(\"Save Data Successfully.............!\");
}
Step 6) double click on delete buttion and we can write c# code in codebehind .cs file.
private void delete_Click(object sender, EventArgs e)
{
string s = \"delete tablename where ID=@id\";
SqlCommand cmd = new SqlCommand(s, con);
con.Open();
cmd.Parameters.AddWithValue(\"@id\",ID);
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show(\"delete data...................!\");
}
Step 7) double click on search buttion and we can write c# code in codebehind .cs file.
private void search_Click(object sender, EventArgs e)
{
BindingSource bs = new BindingSource();
bs.DataSource = dataGridView1.DataSource;
bs.Filter = \"searchname like \'*\" + searchtextboxid.Text + \"*\'\";
dataGridView1.DataSource = bs;
}

