我是 WPF 的新手。我收到以下错误:“System.Data.Common.DbDataReader.GetInt32 的最佳重载消息匹配有一些无效参数”
我的代码如下:
private void comboBoxDisplay_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
string constring = "Data Source=tcp:******.database.windows.net;Initial Catalog=*****;Persist Security Info=True;User ID=*****;Password=******";
string Query = "select * from Rewards where Name='" + comboBoxDisplay.Text + "' ;";
SqlConnection conDataBase = new SqlConnection(constring);
SqlCommand cmdDataBase = new SqlCommand(Query, conDataBase);
SqlDataReader myReader;
try
{
conDataBase.Open();
myReader = cmdDataBase.ExecuteReader();
while (myReader.Read())
{
string sReid = myReader.GetInt32(0).ToString();
string sName = myReader.GetString(1);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}`