this my c windows application form but the 3 buttons u are
this my c# windows application form , but the 3 buttons u are seeing only one works which is the delete button the search button and the save button are not working. can u please tell me what codes should i write behind each of them to work perfectly . by the way, i already uploaded my access database document, and i would want to save to the database and search from it .
Auk m e anythingSolution
//Add these references in the beginning of code-behind file
Using System;
using System.Data.OleDb;
using System.Data;
OleDbConnection con;
//First write the query for inserting the values into the database,next define your connection string,it will be in this format
//Then create the command and open the connection
//Next line is adding the values that you have entered in the textbox or label to the fieldvalues in the table that is created in the database.ExecuteNonquery is the command used for inserting the values into database.
//SEARCH
Double click the search button and write the following code
//First define the connection string and open the connection.(You can define the connection string in the web config and write the name of the connection here or you can define the connection directly in the code-behind file,I have used the second method here)
//Next write the query for retrieving the value from the database.
//string sql = \"SELECT * From tablename where Location=\"+Search.Text // Here I am searching for all the fields in the specifiedtable based on location .Search.Text is the name of the textbox where you enter the location.Suppose you enter xyz in the textbox next to search button and click on search button it will list out all the (DocumentTime,Categoryofincident,Location) fields from the table where the location is xyz.Similary you can search for the results based on your other fields.
//Next create a datatable to hold the values that is retrieved from the database.
//Set the datasource of gridview and then bind it.
