C#数据库编程中出现的列名无效的问题

来源:百度知道 编辑:UC知道 时间:2024/09/23 11:20:34
未处理的“System.Data.SqlClient.SqlException”类型的异常出现在 System.Data.dll 中。
其他信息: 列名 'risfi' 无效。
出错代码:
if (radioButton2.Checked == true)
{

string name = textBox1.Text;
string sql = "select 昵称,账号 from dbo.QQ用户";
SqlCommand cmd = new SqlCommand(sql, myConnection);
SqlDataReader read = cmd.ExecuteReader();
while (read.Read())
{
if (read.GetString(0) == name)
{
Form5 findQQ = new Form5(textBox1.Text);
findQQ.Show();
status = true;
break;
}
}
read.Close();
int rows = cmd.ExecuteNonQuery();

你帖的代码不正确,不是这一段出问题。
你搜索一下risfi,那里使用了这个名字。

那只能说明你程序中的列名和后台数据库表中的列名不符!!!

你看看列名和数据库是否对上