Hi,
try this,
try
{
SqlCommand sqlCommand = new SqlCommand();
using (SqlConnection sqlConnection = new SqlConnection(connectionString))
{
sqlCommand = sqlConnection.CreateCommand();
sqlCommand.CommandText = DBWorker.MSSQLSelectQuery;
SqlDataAdapter sda = new SqlDataAdapter(sqlCommand.CommandText, connectionString);
SqlCommandBuilder scb = new SqlCommandBuilder(sda);
//Create a DataTable to hold the query results.
DataTable dTable = new DataTable();
//Fill the DataTable.
sda.Fill(dTable);
//BindingSource to sync DataTable and DataGridView.
BindingSource bSource = new BindingSource();
//Set the BindingSource DataSource.
bSource.DataSource = dTable;
//Set the DataGridView DataSource.
contentDataGridView.DataSource = bSource;
}
}
catch (SqlException e)
{
//Console.WriteLine(e.StackTrace);
}
sf_hussain786
Rimjhim4, if this helps please login to Mark As Answer. | Alert Moderator