protected void insrt_btn_Click(object sender, EventArgs e) { SqlConnection conn = new SqlConnection("Data Source=192.168.0.11;Initial Catalog=DataRecord;User ID=sa;Password=super"); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandType = CommandType.Text; cmd.CommandText = "Insert into EntryTableTest(Name, [N.I.C], EntryDatetime, ToSee, PurposeOfVisit, VehicalNO) values('" + name_txt.Text + "','" + nic_txt.Text + "','" + System.DateTime.Now + "','" + tosee_txt.Text + "','" + pov_txt.Text + "','" + veh_txt.Text + "')"; conn.Open(); cmd.ExecuteNonQuery(); bindGrid(); conn.Close(); } private void bindGrid() { string connectionString = "Data Source=192.168.0.11;Initial Catalog=DataRecord;User ID=sa;Password=super"; string sql = "SELECT * FROM EntryTableTest"; using (var connection = new SqlConnection(connectionString)) using (var command = new SqlCommand(sql, connection)) using (var adapter = new SqlDataAdapter(command)) { connection.Open(); var dataEntry1 = new DataTable(); adapter.Fill(dataEntry1); GridView1.DataSource = dataEntry1; GridView1.DataBind(); GridView1.Visible = true; }
app.config
web.config
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)