Is there an easier way to use the name and phone variables inside the below insert SQL Command?
String Interpolation is a way but I don't know how to implement this.
String name = textBox1.Text;
String phone = textBox2.Text;
var query = "insert into Customer_info(Customer_Name,Customer_Phone) " +
"values('" + name + "','" + phone + "');";
SqlCommand com = new SqlCommand(query,con);
try {
con.Open();
com.ExecuteNonQuery();
con.Close();
}
catch (Exception Ex) {
con.Close();
}