i have made a script in C# to get index number on database using someparameter on ComboBox.
private int category(string id) {
int identity = 0;
try
{
MySqlConnection conn = new MySqlConnection(connection.mysqlconnectionbuilder());
conn.Open();
MySqlCommand cmd = conn.CreateCommand();
cmd.CommandText = "SELECT kategori.no FROM kategori WHERE kategori.kategori = @id";
cmd.Parameters.AddWithValue("@id", id);
cmd.CommandType = CommandType.Text;
identity = cmd.ExecuteNonQuery();
conn.Close();
}
catch (MySqlException msqe)
{
Console.Write(msqe.ToString());
}
return identity;
}
I want to get Index number based on name example. "Hollywood Movie" --> ID : 2 (in DB) The result from above script is -1.
How to solve that? thanks in advance.