Goran Bibic

Goran Bibic

  • 458
  • 2.9k
  • 201.3k

Need string if har row to show value, else to be ----

Nov 2 2019 7:27 AM
Need string if har row to show value, else to be ----

I try this
What I wrong?
 
  1. string redni_broj = "";  
  2.            using (SqlConnection openCon8 = new SqlConnection(Con))  
  3.            {  
  4.                SqlDataReader reader8;  
  5.                SqlCommand cmd8 = new SqlCommand();  
  6.                cmd8.CommandText = "select FORMAT(redni_broj, '00000') from mp_faktura_lista where id=" + id_fakture;  
  7.                cmd8.Connection = openCon8;  
  8.                openCon8.Open();  
  9.                reader8 = cmd8.ExecuteReader();  
  10.                if (reader8.HasRows)  
  11.                {  
  12.                    while (reader8.Read())  
  13.                    {  
  14.                        redni_broj = reader8[0].ToString();  
  15.                    }  
  16.                }  
  17.                else  
  18.                {  
  19.                    redni_broj = "-----";  
  20.                }  
  21.                openCon8.Close();  
  22.            } 
 

Answers (1)