martnta
New member
- Joined
- Oct 29, 2021
- Messages
- 1
- Programming Experience
- 1-3
getting column anme from table:
public bool checkUser()
{
bool check = false;
SQLiteDataReader reader;
using (SQLiteConnection con = new SQLiteConnection(GetConnetion()))
{
con.Open();
cmd = new SQLiteCommand();
try
{
string query = @"SELECT * FROM user where studentId = @studentID AND password =@password";
cmd.CommandText = query;
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
cmd.Parameters.AddWithValue("@studentID", studentId);
cmd.Parameters.AddWithValue("@password", password);
reader = cmd.ExecuteReader();
while (reader.Read())
{
log_role = reader.GetInt32("role");
}
con.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
check = false;
}
}
return check;
}