If type value non bar code active is line 49 and no have problems multiple times...
Whene coplue times wrong bar code value I have error line 25 on code
If is bar code from database ok working fine, if is bar code not ok firs time is ok, if wronf two times bar code errorr...
Error is INVALID ATTEMP TO READ WHEN NO DATA IS PRESENT
- private void prijavaAction()
- {
- SqlConnection con = new SqlConnection(cs);
- if (textBox1.Text.All(char.IsDigit))
- {
string queryString = "SELECT [ime_prezime] FROM dbo.radnici WHERE bar_kod = '" + textBox1.Text + "'";
- using (SqlConnection connection = new SqlConnection(cs))
- {
- SqlCommand command = new SqlCommand(queryString, connection);
- connection.Open();
- SqlDataReader reader = command.ExecuteReader();
- try
- {
- if (reader.Read())
- {
- notificationPanel.BackColor = System.Drawing.ColorTranslator.FromHtml("#2EFF36");
- messageLabel.Text = (reader["ime_prezime"].ToString()) + " je prijavljen u \n " + DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss");
- readerresultTextbox.Text = (reader["ime_prezime"].ToString());
- }
- else
- {
- notificationPanel.BackColor = System.Drawing.ColorTranslator.FromHtml("#FD7400");
- messageLabel.Text = "Radnik ne postoji u bazi! \nProverite vašu karticu ili probajte ponovo!";
- textBox1.Text = "";
- }
- }
- finally
- {
- if (reader.Read())
- {
-
- }
- else
- {
-
- }
- reader.Close();
- }
- }
- }
- else
- {
- notificationPanel.BackColor = System.Drawing.ColorTranslator.FromHtml("#FD7400");
- messageLabel.Text = "Bar kod nije važeci ili nije bar kod";
- textBox1.Text = "";
- }
- }