Hashtable做为参数如何赋值
下面这句代码执行多条sql语句,以前一直用arraylist做为参数
现在不懂ArrayList和Hashtable哪个性能比较好,区别在哪里
还有要怎么赋值?而且我传进去的sql语句是带参数的,如
(StringBuilder strSql=new StringBuilder();
strSql.Append( "insert into ContractSale( ");
strSql.Append( "Signer,SignTime,IsValid,DeliveryID) ");
strSql.Append( " values ( ");
strSql.Append( "@Signer,@SignTime,@IsValid,@DeliveryID) ");
SqlParameter[] parameters = {
new SqlParameter( "@Signer ", SqlDbType.NVarChar),
new SqlParameter( "@SignTime ", SqlDbType.SmallDateTime),
new SqlParameter( "@IsValid ", SqlDbType.Bit,1),
new SqlParameter( "@DeliveryID ", SqlDbType.Int,4)};
parameters[0].Value = model.Signer;
parameters[1].Value = model.SignTime;
parameters[2].Value = model.IsValid;
parameters[3].Value = model.DeliveryID;)
/// <summary>
/// 执行多条SQL语句,实现数据库事务。
/// </summary>
/// <param name= "SQLStringList "> SQL语句的哈希表(key为sql语句,value是该语句的SqlParameter[]) </param>
public static void ExecuteSqlTran(Hashtable SQLStringList)
{
using (SqlConnection conn = new SqlConnection(connectionString))
{
conn.Open();
using (SqlTransaction trans = conn.BeginTransaction())
{
SqlCommand cmd = new SqlCommand();
try
{
//循环
foreach (DictionaryEntry myDE in SQLStringList)
&nbs