I have those 2 methods in C# on asp.net:
DataTable dt;
protected void Page_Load(object sender, EventArgs e)
{
//Fetch data from mysql database
MySqlConnection conn = new MySqlConnection("server=localhost;uid=root;
password=priya123;database=world;pooling=false;");
conn.Open();
string cmd = "select * from country limit 7";
MySqlDataAdapter dAdapter = new MySqlDataAdapter(cmd, conn);
DataSet ds = new DataSet();
dAdapter.Fill(ds);
dt=ds.Tables[0];
//Bind the fetched data to gridview
GridView1.DataSource = dt;
GridView1.DataBind();
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if(e.CommandName.Equals("detail"))
{
int index = Convert.ToInt32(e.CommandArgument);
string code = GridView1.DataKeys[index].Value.ToString();
IEnumerable<DataRow> query = from i in dt.AsEnumerable()
where i.Field<String>("Code").Equals(code)
select i;
DataTable detailTable = query.CopyToDataTable<DataRow>();
DetailsView1.DataSource = detailTable;
DetailsView1.DataBind();
}
}
now I want to use SQL SERVER. I create a LINQ with DBML.. and have object called 'sdb' with the DataContext. I try to do change it with Lambda expression, but Got an error that the selected row from the lambda is not 'IEnumerable'. how can I casting that to SQL SERVER objects?
thanks!
MySql*
ADO.NET objects toSql*
? – Michael Perrenoud Jan 16 at 13:54