嗨我遇到此错误,当我尝试运行该程序。我相信它是因为在SQL Server中这是一个True还是False? 1还是0?有谁知道如何解决?无法铸造'System.Boolean'类型的对象来键入'System.String'
void StaticS()
{
string constring = "REMOVED";
string Query = "REMOVED";
SqlConnection conDataBase = new SqlConnection(constring);
SqlCommand cmdDataBase = new SqlCommand(Query, conDataBase);
SqlDataReader myReader;
try
{
conDataBase.Open();
myReader = cmdDataBase.ExecuteReader();
while (myReader.Read())
{
string sName = myReader.GetString(0);
comboBox17.Items.Add(sName);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
哇这么简单的Fix哈哈。谢谢! – user3014698
请你解释一下吗? –
对不起,请解释一下?为什么我建议使用索引器和ToString()而不是GetBoolean()?由于请求中有此操作的返回值。 –