/// <Summary>
/// General Addition
/// </Summary>
/// <Param name = "ht"> hashtable </param>
/// <Param name = "tablename"> table name </param>
/// <Returns> bool </returns>
Public bool insert (hashtable HT, string tablename)
{
Try
{
// Obtain the hashtable object for circular access
System. Collections. idictionaryenumerator id = Ht. getenumerator ();
String SQL = "";
String sql1 = "";
String sql2 = "";
Openconnection ();
Sqlcommand COM = new sqlcommand (SQL, strconn );
// Transaction
If (istran)
{
Com. Transaction = m_tran;
}
// Construct an SQL statement by traversing the loop
While (Id. movenext ())
{
Sql1 + = ID. Key + ",";
Sql2 + = "@" + id. Key + ",";
}
Sql1 = sql1.substring (0, sql1.length-1 );
Sql2 = sql2.substring (0, sql2.length-1 );
SQL = "insert into" + tablename + "with (rowlock) (" + sql1 + ") values (" + sql2 + ")";
//
Com. commandtext = SQL;
// Returns the initial value.
Id. Reset ();
// Construct sqlparameter through Traversal
While (Id. movenext ())
{
Sqlparameter sp = new sqlparameter ("@" + id. Key, id. value. GetType ());
Sp. value = ID. value;
Com. Parameters. Add (SP );
}
Return convert. toboolean (COM. executenonquery ());
}
Catch (exception ex)
{
If (istran)
{
// Rollback
Rollbacktransaction ();
}
This. strmessage = ex. message;
Return false;
}
}