Fill DataGridView by SqlConnection

Published: 13 August 2012
on channel: Ashish Jaryal
920
1

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WA_Table_Udao
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
SqlConnection thisConnection = new SqlConnection(@"Data Source=HOME-PC\SQL2K8;Initial Catalog=ACCOUNTING1;Integrated Security=True");
private void button1_Click(object sender, EventArgs e)
{
//SqlConnection thisConnection = new SqlConnection(@"Data Source=HOME-PC\SQL2K8;Initial Catalog=ACCOUNTING1;Integrated Security=True");
SqlDataAdapter thisAdapter=new SqlDataAdapter("Select ColumnId,ColumnName From table_bnao",thisConnection);

SqlCommandBuilder thisCommandBuilder = new SqlCommandBuilder(thisAdapter);
DataSet thisDataSet = new DataSet();
thisAdapter.Fill(thisDataSet, "table_bnao");
//richTextBox1.Text = "";
//richTextBox1.Text += thisDataSet.Tables["table_bnao"].Rows[0][0];
dataGridView1.DataSource = thisDataSet.Tables["table_bnao"];


}

private void button2_Click(object sender, EventArgs e)
{
textBox1.Text = dataGridView1.CurrentCell.Value.ToString();
}

private void button3_Click(object sender, EventArgs e)
{
dataGridView1.Rows.Remove(dataGridView1.CurrentRow);
}
}
}


On this page of the site you can watch the video online Fill DataGridView by SqlConnection with a duration of hours minute second in good quality, which was uploaded by the user Ashish Jaryal 13 August 2012, share the link with friends and acquaintances, this video has already been watched 920 times on youtube and it was liked by 1 viewers. Enjoy your viewing!