using (StreamReader sr = new StreamReader(openpath)) { // read the text }
namespace CS_Sistem_Managemen_Restoran { class DataAccess { public SqlConnection con; public void Connection(string spName = null) { string strConnect = "Server=PC\\SQLEXPRESS;Database=MyLoginApp;Trusted_Connection=True;"; SqlConnection conn = new SqlConnection(); SqlConnection dt = new SqlConnection(); try { //Connect to the database conn = new SqlConnection(strConnect); conn.Open(); //Execute command SqlCommand cmd = new SqlCommand(spName, conn); SqlCommand command = conn.CreateCommand(); SqlDataReader dr = cmd.ExecuteReader(); } catch (Exception ex) { } } } }
this's my form1 Button private void btnHitung_Click(object sender, EventArgs e) { DataAccess conn = new DataAccess(); conn.Connection(); DataTable dt = new DataTable("Products"); //declare Double BasoSUCost = Convert.ToInt32(dt.Rows[1]["price"].ToString()); Double ItemBasoSU; Double HargaBasoSU; if (int.TryParse(txtBasoSU.Text, out NumberofOrder)) { ItemBasoSU = Double.Parse(txtBasoSU.Text); HargaBasoSU = BasoSUCost * ItemBasoSU; txtTotal.Text = String.Format("Rp. {0:N} ", HargaBasoSU); }
Double BasoSUCost = Convert.ToInt32(dt.Rows[1]["price"].ToString());