Amrul Hakim

Amrul Hakim

  • NA
  • 19
  • 3.9k

How to display the number row records in sql to textbox?

May 15 2017 11:13 AM
this my code ;
 Thank you
  1. public MainDashboar_C()  
  2.         {  
  3.             InitializeComponent();  
  4.         }  
  5.         SqlConnection conn = new SqlConnection(@"Data Source=AM-PC\SQLEXPRESS;Initial Catalog=Management_Gudang;Integrated Security=True");  
  6.         public SqlDataReader READER;  
  7.   
  8.         private void Tampikan_Label()  
  9.         {  
  10.             conn.Open();  
  11.             SqlCommand CMD = new SqlCommand("Select COUNT(*) From Stok_Barang ", conn);  
  12.             READER = CMD.ExecuteReader();  
  13.             if (READER.HasRows)  
  14.             {  
  15.                 txt_BarangMasuk.Text = READER.ToString();  
  16.             }  
  17.             Else
  18.             {
  19.               txt_BarangMasuk.Text = "0";
  20.             }
  21.         }  

Answers (2)