请不要给我类似下面的代码
void Datagrid1_Delete(Object sender, DataGridCommandEventArgs e)
{
// get the ID of the record to update
int empID = (int)Datagrid1.DataKeys[e.Item.ItemIndex];
// create the connection and the DELETE command
string connString = "server=(local);database=Northwind;uid=sa;pwd=;";
string sql = @"DELETE FROM Employees WHERE EmployeeID = " + empID.ToString();
SqlConnection conn = new SqlConnection(connString);
SqlCommand cmd = new SqlCommand(sql, conn);
// execute the command
cmd.Connection.Open();
try {
cmd.ExecuteNonQuery();
}
catch (SqlException) {
// handle exception...
}
finally {
cmd.Connection.Close();
}
// rebind the grid
Datagrid1.EditItemIndex = -1;
BindGrid();
}
我要知道的是如何使用软件自动产生的InitializeComponent()方法中的相关这些属性的使用。
void Datagrid1_Delete(Object sender, DataGridCommandEventArgs e)
{
// get the ID of the record to update
int empID = (int)Datagrid1.DataKeys[e.Item.ItemIndex];
// create the connection and the DELETE command
string connString = "server=(local);database=Northwind;uid=sa;pwd=;";
string sql = @"DELETE FROM Employees WHERE EmployeeID = " + empID.ToString();
SqlConnection conn = new SqlConnection(connString);
SqlCommand cmd = new SqlCommand(sql, conn);
// execute the command
cmd.Connection.Open();
try {
cmd.ExecuteNonQuery();
}
catch (SqlException) {
// handle exception...
}
finally {
cmd.Connection.Close();
}
// rebind the grid
Datagrid1.EditItemIndex = -1;
BindGrid();
}
我要知道的是如何使用软件自动产生的InitializeComponent()方法中的相关这些属性的使用。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货