

When we run the code a window will show with a datagridview that containing all the returning rows. dataGridView1.DataSource = ds.Tables is used to specify the data source of datagridview and the table which will be bind to.connection.Close() it is used to close the Database Connection. dataadapter.Fill(ds) specifies to fetches the data from User and fills in the DataSet ds. connection.Open() specifies to Open the SqlConnection.SqlDataAdapter dataadapter = new SqlDataAdapter(sql, connection) specifies to initializes a new instance of the SqlDataAdapter class with a SelectCommand (sql) and a SqlConnection object(connection). SqlConnection connection = new SqlConnection (connectionString) this statement is used to acquire the SqlConnection as a resource.In this example string sql = "SELECT * FROM login_table" specifies to select the login_table in SQL server. The default value is user id and password is venkat. string connectionString = Source=VENKAT\KAASHIV Initial Catalog=wikitechy user id = venkat password=venkat" connection string specifies that includes the source database name here the name is VENKAT\KAASHIV, and other parameters needed to establish the initial catalog connection is wikitechy.MessageBox.Show((e.RowIndex + 1) + " Row " + (e.ColumnIndex + 1) +Ĭlick below button to copy the code. Private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) SqlDataAdapter dataadapter = new SqlDataAdapter(sql, connection)

SqlConnection connection = new SqlConnection(connectionString) String sql = "SELECT * FROM login_table" String connectionString = Source=VENKAT\KAASHIV Initial Catalog=wikitechy Private void button1_Click(object sender, EventArgs e) Namespace WikiTechy_Csharp_Windows_Application
