-3

错误 1 ​​当前上下文中不存在名称“tblstudent”

void FillNationality()
{
    SqlConnection connection = new SqlConnection();
    connection.ConnectionString = "Integrated Security=true; Initial Catalog = student; Data Source = Yudish-PC";
    connection.Open();
    SqlDataAdapter d = new SqlDataAdapter("select country from tbl_nationality", connection);
    DataSet dt = new DataSet();
d.Fill(dt);
    cmbnationality.DataSource = dt.Tables[0]; /// assign the first table of dataset
    cmbnationality.DisplayMember = "country";  /// assign the column country to be displayed
    cmbnationality.DataBindings.Add("SelectedValue", tblstudent, "nationality_id");                                          

    connection.Close();
}
4

1 回答 1

0

在代码中

cmbnationality.DataBindings.Add("SelectedValue", tblstudent, "nationality_id");  

tblstudent 未定义,在方法的当前范围内

于 2013-04-23T17:55:41.347 回答