Skip to main content

Posts

Showing posts from January, 2013

How to Bind the DataGridView with DataSet and DataTable

We can bind the DataGridView in C#.net with the help of following code:        SqlConnection vConn = new SqlConnection("Server=localhost; database=rohit; user id=sa; pwd=***");             vConn.Open();             String vQuery = textBox1.Text;             SqlDataAdapter vAdap = new SqlDataAdapter(vQuery, vConn);             DataSet vDs = new DataSet();             vAdap.Fill(vDs, "Emp");             dataGridView1.DataBindings.Clear();             DataTable vDt = vDs.Tables["Emp"];             dataGridView1.DataSource = vDs;             dataGridView1.DataMember = "Emp";             vConn.Close(); //BIND THE LISTBOX WITH THE COLUMN FROM DATABASE. SqlC...

How to call Stored Procedure and use of ExecuteReader and Excecute Scalar

The following code demonstrates few things in C#.NET: //CALLING THE STORED PROCEDURE IN SQL SERVER SqlConnection conn = new SqlConnection ( "Server=(local);DataBase=Rohit;Integrated Security=SSPI" );             conn.Open();             int vEmpno;             String vEname;             int vSalary;             //insert command             //Pick all the values from the textboxes             vEmpno = Convert .ToInt32(textBox1.Text);             vEname = textBox2.Text;         ...

Coding for ADO.NET Online Method.

This post is for the Online Method Database (Connected Approach) in .NET Framework. Following are the three methods to do the same: OLEDB Method OleDbConnection vConn = new OleDbConnection( "provider=microsoft.jet.oledb.4.0; data source=c:\\MyDatabase.mdb" );             vConn.Open();              int vEmpno;             String vEname;             int vSalary;             //insert command             //Pick all the values from the textboxes             vEmpno = Convert.ToInt32(textBox1.Text);             vEname = textBo...