2设定全局变量:
MySqlConnection conn;
MySqlDataAdapter adapter;
MySqlTransaction trans;
3 // 数据库联接
private SystemDataDataTable dbconn(string strSql)
{
string strconn = "host=localhost;database=test;user id=root;password=";
conn = new MySqlConnection();
connConnectionString = strconn;
connOpen();
thisadapter = new MySqlDataAdapter(strSql, conn);
SystemDataDataTable dtSelect = new SystemDataDataTable();
int rnt=thisadapterFill(dtSelect);
connClose();
return dtSelect;
}
4 //设定DataGridView的样式
private void setDgStyle()
{
thisdgselectColumnsClear();
DataGridViewCheckBoxColumn colDel = new DataGridViewCheckBoxColumn();
colDelDataPropertyName = "Del";
colDelName = "Del";
colDelSelected = false;
colDelFalseValue = "0";
colDelTrueValue = "1";
colDelWidth = 40;
colDelSortMode = DataGridViewColumnSortModeNotSortable;
colDelHeaderText = "删除";
colDelHeaderCellStyleAlignment = DataGridViewContentAlignmentMiddleCenter;
colDelDefaultCellStyleAlignment = DataGridViewContentAlignmentMiddleCenter;
thisdgselectColumnsInsert(0, colDel);
DataGridViewTextBoxColumn colID = new DataGridViewTextBoxColumn();
colIDDataPropertyName = "ProductsSpecID";
colIDName = "ProductsSpecID";
colIDHeaderCellStyleAlignment = DataGridViewContentAlignmentMiddleCenter;
colIDHeaderText = "产品规格ID";
colIDWidth = 160;
thisdgselectColumnsInsert(1, colID);
DataGridViewTextBoxColumn colNM = new DataGridViewTextBoxColumn();
colNMDataPropertyName = "ProductsSpec";
colNMName = "ProductsSpec";
colNMHeaderCellStyleAlignment = DataGridViewContentAlignmentMiddleCenter;
colNMHeaderText = "产品规格名称";
colNMWidth = 160;
thisdgselectColumnsInsert(2, colNM);
DataGridViewTextBoxColumn colUnit = new DataGridViewTextBoxColumn();
colUnitDataPropertyName = "ProductsSpecUnit";
colUnitName = "ProductsSpecUnit";
colUnitHeaderCellStyleAlignment = DataGridViewContentAlignmentMiddleCenter;
colUnitHeaderText = "产品规格单位";
colUnitWidth = 180;
thisdgselectColumnsInsert(3, colUnit);
DataGridViewTextBoxColumn colPID = new DataGridViewTextBoxColumn();
colPIDDataPropertyName = "ProductsID";
colPIDName = "ProductsID";
colPIDHeaderCellStyleAlignment = DataGridViewContentAlignmentMiddleCenter;
colPIDHeaderText = "产品ID";
colPIDWidth = 140;
thisdgselectColumnsInsert(4, colPID);
DataGridViewButtonColumn colButton = new DataGridViewButtonColumn();
colButtonDataPropertyName = "colSearch";
colButtonName = "colSearch";
colButtonHeaderCellStyleAlignment = DataGridViewContentAlignmentMiddleCenter;
colButtonHeaderText = "Button";
colButtonWidth = 80;
thisdgselectColumnsInsert(5, colButton);
thisdgselectRowHeadersWidth = 15;
thisdgselectColumnHeadersDefaultCellStyleFont=new SystemDrawingFont("宋体",14);
}
5 //修改数据,并将数据提交到数据库
private Boolean dbUpdate()
{
string strSql = "select ProductsSpecID,ProductsSpec,ProductsSpecUnit,ProductsID from tbl_product_detail_master";
SystemDataDataTable dtUpdate = new SystemDataDataTable();
dtUpdate = thisdbconn(strSql);
dtUpdateRowsClear();
SystemDataDataTable dtShow = new SystemDataDataTable();
//dtShow = (DataTable)thisbindSourceDataSource;
dtShow = (SystemDataDataTable)thisdgselectDataSource;
int p1 = dtShowRowsCount;
// try
// {
for (int i = 0; i < dtShowRowsCount; i++)
{
DataRowState rowState=new DataRowState();
rowState=dtShowRows[i]RowState;
if (rowState==DataRowStateAdded || rowState==DataRowStateDetached || rowState==DataRowStateModified)
{
if (thisdgselect["Del", i]ValueToString() == "1")
{
dtShowRows[i]Delete();
}
}
}
for (int i = 0; i < dtShowRowsCount; i++)
{
dtUpdateImportRow(dtShowRows[i]);
}
int num = dtUpdateRowsCount;
try
{
thisconnOpen();
trans = thisconnBeginTransaction();
MySqlCommandBuilder CommandBuiler;
CommandBuiler = new MySqlCommandBuilder(thisadapter);
thisadapterUpdate(dtUpdate);
transCommit();
thisconnClose();
}
catch ( Exception ex)
{
MessageBoxShow(exMessageToString());
transRollback();
return false;
}
dtUpdateAcceptChanges();
return true;
}要删除mac上的SMB文件服务器凭证,可以按照以下步骤进行 *** 作:
打开“钥匙串访问”应用程序,可以在“应用程序”文件夹中找到该应用程序。
在“钥匙串访问”应用程序中,找到要删除的SMB文件服务器凭证。可以通过搜索关键字来查找凭证。
选中要删除的SMB文件服务器凭证,然后单击鼠标右键,选择“删除”。
确认要删除该凭证,输入管理员密码。
凭证删除成功后,可以关闭“钥匙串访问”应用程序。
以上步骤可以帮助你删除mac上的SMB文件服务器凭证,以便重新输入凭证信息进行连接。
根据ID删除mysql表中的数据方法:
例如有一个员工表,表中有员工ID、员工姓名、员工薪资等等信息,我们需要将ID=1的员工信息从表中删除。只需要如下代码即可:
mysql_connect 连接数据库服务器,数据库服务器地址为mysql153secureservernet 登录账号为root 密码为password
mysql_select_db 选择数据库,这里选择了名称为manongjc的数据库
mysql_query 执行SQL名称,这里的sql为:DELETE FROM Employee WHERE ID=1
delete afrom [10561096]EMSdboems_pm_data a
join [10561096]EMSdboEMS_Machine_Status b
on aEnrolNo = bEnrolNo
where apm_userid='52060' AND bFinish_DT<'2013-06-19'。
delete后面跟对象别名
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)