求c/s模式下 C#编程数据链接类 :用微软的sqlhelper类编写的

billlyh 2005-07-14 05:18:18
用微软的sqlhelper类编写的,通过此类对数据库增删改,发到论坛或我邮箱billlyh@163.com
100分回送!!!!!!!!!!!!1
...全文
142 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
thinkingforever 2005-07-14
  • 打赏
  • 举报
回复
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();
}
}

110,571

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧