public partial class _Default : System.Web.UI.Page { SqlConnection connectionString = new SqlConnection("Data Source=AZHAR-PC\\SQLEXPRESS;Initial Catalog=Emp_DB;Integrated Security=True"); SqlCommand commandString; protected void Page_Load(object sender, EventArgs e) { connectionString.Open(); } protected void btnInsert_Click(object sender, EventArgs e) { String query; query = "insert into SalesEmpTable values(" +txtId.Text+ ",'" + txtName.Text + "' , " + txtOrder + ")"; commandString = new SqlCommand(query, connectionString); int record = commandString.ExecuteNonQuery(); lblStatus.Text = "Status: Successfully Inserted"; commandString.Dispose(); } }
INSERT INTO tablename (col1,col2col3) values ('a','b','c')
query = "insert into SalesEmpTable values(" +txtId.Text+ ",'" + txtName.Text + "' , " + txtOrder + ")";
query = "insert into SalesEmpTable values(" +txtId.Text+ "," + txtName.Text + " , " + txtOrder + ")";
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)