【发布时间】:2016-04-01 14:22:19
【问题描述】:
我目前正在使用 Visual Studio 2015 和 SQL Server 为一个商业社会开展一个小型项目。我有两个组合框“AccountCode”和“AccountNo”。我想制作“AccountNo”组合框以根据从“AccountCode”下拉列表中选择文本来更改其值。但我收到以下错误:
System.Data.dll 中出现“System.Data.SqlClient.SqlException”类型的异常,但未在用户代码中处理
附加信息:无法绑定多部分标识符“System.Data.DataRowView”。
private void cmBxAccountCode_DataEntry_SelectedIndexChanged(object sender, EventArgs e)
{
cmBxAccountNo_DataEntry.ResetText();
cmBxAccountNo_DataEntry.Refresh();
DataSet ds = new DataSet();
da.SelectCommand = new SqlCommand("SELECT ID,ACCOUNTNO FROM AccountHolder WHERE ACCOUNTCODE =" + cmBxAccountCode_DataEntry.Text, SQLConnection.con);
da.Fill(ds);
cmBxAccountNo_DataEntry.DataSource = ds.Tables[0];
cmBxAccountNo_DataEntry.DisplayMember = "ACCOUNTNO";
cmBxAccountNo_DataEntry.ValueMember = "ID";
}
【问题讨论】: