int value2;
using (SqlConnection dataConnection = new SqlConnection(@"Data Source=MANNAN-PC\SQLEXPRESS;Initial Catalog=WareHouse;Integrated Security=True;"))
using (SqlCommand dataCommand = new SqlCommand("Select Sum(I_Quantity) from Itemswork where I_Detail='" + maskedTextBox2.Text + "' and Order_No ='" + maskedTextBox1.Text + "'", dataConnection))
{
dataConnection.Open();
value2 = Convert.ToInt32(dataCommand.ExecuteScalar());
}
It shows the Error of DBnull because the column from which I'm getting the value is already int
. I want to know what is the other way to get that value in variable's value2
definition.