0
我在登录表单上收到此错误。我不确定是否修复它,因为我不知道什么是错的。InvalidOperationException:无当前行错误
出现InvalidOperationException:没有当前行
当我启动应用程序,它崩溃。
private void buttonLogin_Click(object sender, EventArgs e)
{
SQLiteConnection conn = new SQLiteConnection("data source = zivali_v2.sqlite");
conn.Open();
SQLiteCommand com = new SQLiteCommand(conn);
com.CommandText = "SELECT * FROM login;";
SQLiteDataReader reader = com.ExecuteReader();
string username = reader["username"].ToString();
string password = reader["password"].ToString();
bool loginValid = false;
while (reader.Read())
{
if (username == textBoxUserName.Text && password == textBoxPassword.Text)
{
loginValid = true;
break;
}
}
if (loginValid)
{
MessageBox.Show("OK");
}
else
{
MessageBox.Show("Wrong username or password");
}
conn.Close();
}
嘿,连接字符串有什么问题? 'SQLiteConnection conn = new SQLiteConnection(“data source = zivali_v2.sqlite”);' –
你是什么意思。你认为我的连接是问题吗? – krneki
可能是这样,但奇怪的是你没有在conn.open()函数上发生错误。你试图连接什么数据库? –