PDA

View Full Version : سوال: خطا در ds.Tables[0].Rows[3]["fn"]



mehran63
پنج شنبه 02 شهریور 1391, 16:47 عصر
چرا در خط زیر پیغام خطا میدهد
Label1 = ds.Tables[0].Rows[3]["fn"];


SqlConnection con = new SqlConnection();
string str = "Data Source=localhost; initial Catalog=my-db; Integrated Security=True";
con.ConnectionString = str;
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = @"select * from mytb";
da.SelectCommand = cmd;
da.Fill(ds);
Label1 = ds.Tables[0].Rows[3]["fn"];

پیام خطا:

Cannot implicitly convert type 'object' to 'System.Web.UI.WebControls.Label'. An explicit conversion exists (are you missing a cast?)

tooraj_azizi_1035
پنج شنبه 02 شهریور 1391, 17:07 عصر
Label1.Text