Note: If you want Documents of this code then join our Groups
Click to join DotNetBD_VB_CsHARP
Dot net Framework 2.0 is easy to design software or web page.This platform can easily create various management software and also web application.In dot net framework 2.0 have three different languages vb,c# and j#.I discussed about two languages.I think it is helpful for new programmer.Best of luck.Thanks .Parves.
Click to join DotNetBD_VB_CsHARP
Click to join DotNetBD_VB_CsHARP
|
Click to join DotNetBD_VB_CsHARP
----------------------------------------------------------------------------------------------
In this article, we will see how to create a database connection between ASP.NET(C#).We will explore design a website and write server code for this project.
In this articles insert, update, delete and search data from MS access database ASP.NET 2.0 and ASP.NET 3.5 (language C#).we had discussed how to save and retrieve images in the database. In this article, we will build on that concept and use the same technique to display data in a grid view.
We will learn how to insert an data and then display the data on the same page with details view . At the end of this article, you will also learn how to use the database in ASP.NET 2.0 and ASP.NET 3.5 (language C#). If you are unfamiliar with the gridview control, I suggest you to read the gridview control in ASP.NET 3.5 to get an understanding of the same
Let us start off by first creating a sample database and adding a table to it. We will call the database ‘SampleDB’ and the table will be called ‘Info_TBL’. This table will contain some column along with some other columns.
Step 1: Create a new ASP.NET website. In the code-behind, add the following namespace
C#
Step 2: Drag and drop table, label, textbox and button control as much we need. Also drag drop some validation control as we need. The source would look similar to the following:
And Snap shot of this code is
Connection string is
Step 3: In the button click event, add the following code:
C#
In the code above, we are creating a connetion. In this connection four operations are performed.
Step 4: In order to display the data Gridview on the page, first we will add a Gridview then we will create another connections and query String then we will bind the whole data with Gridview.
void LoadData()
{
OleDbConnection cn = new OleDbConnection(ConnectionStringSampleDB);
cn.Open();//Open connection
string strserch = "Select * from Info_TBL";
OleDbDataAdapter da = new OleDbDataAdapter(strserch, cn);
DataSet ds = new DataSet();
da.Fill(ds, "Info_TBL");// load data into adadpter
GridView1.DataSource = ds;
GridView1.DataBind();// finally bind in datagrid
}
void Clear_Data()
{
txtName.Text = string.Empty;
txtEmail.Text = string.Empty;
txtPhone.Text = string.Empty;
txtJob.Text = string.Empty;
txtAdd.Text = string.Empty;
txtComments.Text = string.Empty;
}
All then connections techniques are explain if u want to download source code of this Connection please Go to this link. Source Code