求c/s模式下 C#编程数据链接类 :用微软的sqlhelper类编写的 用微软的sqlhelper类编写的,通过此类对数据库增删改,发到论坛或我邮箱[email protected]100分回送!!!!!!!!!!!!1 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public void update_AQ_SafetyEvaluate(DataSet ds) { this.sqlConnection = new System.Data.SqlClient.SqlConnection(); this.sqlConnection.ConnectionString=strConn; this.sqlConnection.Open(); this.sqlInsertCommand = new System.Data.SqlClient.SqlCommand(); this.sqlUpdateCommand = new System.Data.SqlClient.SqlCommand(); this.sqlDeleteCommand = new System.Data.SqlClient.SqlCommand(); try { // // sqlInsertCommand // this.sqlInsertCommand.CommandText = @"INSERT INTO AQ_SafetyEvaluate(Date, ConstructLoc, MorSafetyValue, MinSafetyValue, NiSafetyValue, ExistProblem, DepNo) VALUES (@Date, @ConstructLoc, @MorSafetyValue, @MinSafetyValue, @NiSafetyValue, @ExistProblem, @DepNo)"; this.sqlInsertCommand.Connection = this.sqlConnection; this.sqlInsertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Date", System.Data.SqlDbType.DateTime, 8, "Date")); this.sqlInsertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ConstructLoc", System.Data.SqlDbType.VarChar, 100, "ConstructLoc")); this.sqlInsertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@MorSafetyValue", System.Data.SqlDbType.Float, 8, "MorSafetyValue")); this.sqlInsertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@MinSafetyValue", System.Data.SqlDbType.Float, 8, "MinSafetyValue")); this.sqlInsertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@NiSafetyValue", System.Data.SqlDbType.Float, 8, "NiSafetyValue")); this.sqlInsertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ExistProblem", System.Data.SqlDbType.VarChar, 100, "ExistProblem")); this.sqlInsertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@DepNo", System.Data.SqlDbType.VarChar, 10, "DepNo")); // // sqlUpdateCommand // this.sqlUpdateCommand.CommandText = @"UPDATE AQ_SafetyEvaluate SET Date = @Date, ConstructLoc = @ConstructLoc, MorSafetyValue = @MorSafetyValue, MinSafetyValue = @MinSafetyValue, NiSafetyValue = @NiSafetyValue, ExistProblem = @ExistProblem, DepNo = @DepNo WHERE (ID = @Original_ID)"; this.sqlUpdateCommand.Connection = this.sqlConnection; this.sqlUpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Date", System.Data.SqlDbType.DateTime, 8, "Date")); this.sqlUpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ConstructLoc", System.Data.SqlDbType.VarChar, 100, "ConstructLoc")); this.sqlUpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@MorSafetyValue", System.Data.SqlDbType.Float, 8, "MorSafetyValue")); this.sqlUpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@MinSafetyValue", System.Data.SqlDbType.Float, 8, "MinSafetyValue")); this.sqlUpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@NiSafetyValue", System.Data.SqlDbType.Float, 8, "NiSafetyValue")); this.sqlUpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ExistProblem", System.Data.SqlDbType.VarChar, 100, "ExistProblem")); this.sqlUpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@DepNo", System.Data.SqlDbType.VarChar, 10, "DepNo")); this.sqlUpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_ID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ID", System.Data.DataRowVersion.Original, null)); // // sqlDeleteCommand // this.sqlDeleteCommand.CommandText = @"DELETE FROM AQ_SafetyEvaluate WHERE (ID = @Original_ID)"; this.sqlDeleteCommand.Connection = this.sqlConnection; this.sqlDeleteCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_ID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ID", System.Data.DataRowVersion.Original, null)); SqlHelper.UpdateDataset(this.sqlInsertCommand,this.sqlDeleteCommand,this.sqlUpdateCommand,ds,ds.Tables[0].TableName); } catch(Exception ex) { finally { this.sqlConnection.Close(); } } C#Socket实现局域网发送图片 combobox控件 无法取出选中项目 如何编写一个拷贝文件的exe文件? datagridview,不能加新行? 选中checkbox改变背景色 【版务帖】2009年10月C#版务帖 没分了。跪求C#与VB6 SOCKET通讯中文乱码解决方案。 在线等候 C#代码里怎么启动Ms 的PPPoE虚拟拨号? 动态创建控件的问题 帅哥靓妹帮忙,谢谢! 关于往DataView里AddNew的问题 在windows control中添加了panel控件,然后在其中显示图片,设定其AutoScroll = true;有两个问题!
{
this.sqlConnection = new System.Data.SqlClient.SqlConnection();
this.sqlConnection.ConnectionString=strConn;
this.sqlConnection.Open();
this.sqlInsertCommand = new System.Data.SqlClient.SqlCommand();
this.sqlUpdateCommand = new System.Data.SqlClient.SqlCommand();
this.sqlDeleteCommand = new System.Data.SqlClient.SqlCommand();
try
{
//
// sqlInsertCommand
//
this.sqlInsertCommand.CommandText = @"INSERT INTO AQ_SafetyEvaluate(Date, ConstructLoc, MorSafetyValue, MinSafetyValue, NiSafetyValue, ExistProblem, DepNo) VALUES (@Date, @ConstructLoc, @MorSafetyValue, @MinSafetyValue, @NiSafetyValue, @ExistProblem, @DepNo)";
this.sqlInsertCommand.Connection = this.sqlConnection;
this.sqlInsertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Date", System.Data.SqlDbType.DateTime, 8, "Date"));
this.sqlInsertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ConstructLoc", System.Data.SqlDbType.VarChar, 100, "ConstructLoc"));
this.sqlInsertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@MorSafetyValue", System.Data.SqlDbType.Float, 8, "MorSafetyValue"));
this.sqlInsertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@MinSafetyValue", System.Data.SqlDbType.Float, 8, "MinSafetyValue"));
this.sqlInsertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@NiSafetyValue", System.Data.SqlDbType.Float, 8, "NiSafetyValue"));
this.sqlInsertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ExistProblem", System.Data.SqlDbType.VarChar, 100, "ExistProblem"));
this.sqlInsertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@DepNo", System.Data.SqlDbType.VarChar, 10, "DepNo"));
//
// sqlUpdateCommand
//
this.sqlUpdateCommand.CommandText = @"UPDATE AQ_SafetyEvaluate SET Date = @Date, ConstructLoc = @ConstructLoc, MorSafetyValue = @MorSafetyValue, MinSafetyValue = @MinSafetyValue, NiSafetyValue = @NiSafetyValue, ExistProblem = @ExistProblem, DepNo = @DepNo WHERE (ID = @Original_ID)";
this.sqlUpdateCommand.Connection = this.sqlConnection;
this.sqlUpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Date", System.Data.SqlDbType.DateTime, 8, "Date"));
this.sqlUpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ConstructLoc", System.Data.SqlDbType.VarChar, 100, "ConstructLoc"));
this.sqlUpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@MorSafetyValue", System.Data.SqlDbType.Float, 8, "MorSafetyValue"));
this.sqlUpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@MinSafetyValue", System.Data.SqlDbType.Float, 8, "MinSafetyValue"));
this.sqlUpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@NiSafetyValue", System.Data.SqlDbType.Float, 8, "NiSafetyValue"));
this.sqlUpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ExistProblem", System.Data.SqlDbType.VarChar, 100, "ExistProblem"));
this.sqlUpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@DepNo", System.Data.SqlDbType.VarChar, 10, "DepNo"));
this.sqlUpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_ID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ID", System.Data.DataRowVersion.Original, null));
//
// sqlDeleteCommand
//
this.sqlDeleteCommand.CommandText = @"DELETE FROM AQ_SafetyEvaluate WHERE (ID = @Original_ID)";
this.sqlDeleteCommand.Connection = this.sqlConnection;
this.sqlDeleteCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_ID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ID", System.Data.DataRowVersion.Original, null));
SqlHelper.UpdateDataset(this.sqlInsertCommand,this.sqlDeleteCommand,this.sqlUpdateCommand,ds,ds.Tables[0].TableName);
}
catch(Exception ex)
{
finally
{
this.sqlConnection.Close();
}
}