i am making a system now, using C# winforms, and mysql database, and there is a part there that I want to check first if the id exist in the database, and if there is no record it will proceed to a certain procedure, but i am getting an error of Object not reference not set, how can I fix it? , thanks to those who will answer
Here is my sample code
string constring2 = "datasource='localhost';port='3306';username='root';password=1234";
string query2 = "select count(*) from betahms.billing where patient_id = '"+ textBox1.Text +"' ;";
MySqlConnection conDataBase2 = new MySqlConnection(constring2);
MySqlCommand cmdDataBase2 = new MySqlCommand(query2, conDataBase2);
int count = (int)cmdDataBase2.ExecuteScalar();
if (count > 0)
{
//do something
}