Code:private void MedIDGenerator() { try { oleDbConnection1.Open(); oleDbDataAdapter1.SelectCommand.CommandText = "SELECT [Med ID] FROM Pharmacy ORDER BY [Med ID] DESC" ; oleDbDataAdapter1.SelectCommand.ExecuteNonQuery(); int recordCount = (Int32) oleDbDataAdapter1.SelectCommand.ExecuteScalar(); //update the Med ID textbox with the Number of records present plus one. recordCount++; txtMedID.Text = recordCount.ToString() ; } catch(Exception e) { MessageBox.Show("Error in connecting! "+e.ToString(), "Error"); } finally { oleDbConnection1.Close(); oleDbConnection1.Dispose(); }
how do i make the counter start from 0, at this moment if the database is empty it gives me a logical error..but if there's a record in it, it works fine...what's wrong...how do i make it start from zero?...
thx in advance




Reply With Quote