//using System.Data.Common;
//using System.Web.Configuration;
//isim uzaylarını ekleyin
string dtProvider = WebConfigurationManager.ConnectionStrings[“NorthwindConnectionString”].ProviderName;
DbProviderFactory dataFactory = DbProviderFactories.GetFactory(dtProvider);
DbConnection con = dataFactory.CreateConnection();
con.ConnectionString = WebConfigurationManager.ConnectionStrings[“NorthwindConnectionString”].ConnectionString;
DbCommand cmd = con.CreateCommand();
cmd.CommandText = “Select * from Categories”;
try
{
con.Open();
DbDataReader rd = cmd.ExecuteReader();
GridView1.DataSource = rd;
GridView1.DataBind();
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
finally
{
con.Close();
}
Source: rss