日期:2014-05-17 浏览次数:20407 次
[WebMethod]
//tast 实体
public bool InsertList(tast sct)
{
List<DateHelper> List = null;//一个用来保存sql语句和值的类
bool Test=false;//用于记录插入是否成功
string tableAC1= "tableAC1";//表tableAC1
string tableAB1= "tableAB1";//表tableAB1
for (int i = 1; i <=50; i++)
{
List = new List<DateHelper>();
string SQL1="insert into "+tableAC1+i+"(.....)values(....)";
SqlParameter[] Par1 = new SqlParameter[]{
..
...
};
..
...
string SQL2="insert into "+tableAB1+i+"(.....)values(....)"
SqlParameter[] Par1 = new SqlParameter[]{
..
...
};
..
...
SqlDbHelper db = new SqlDbHelper();
if (db.ExecuteSqlTran(List) > 0)//执行成功返回true否则else
{
Test = true;
}
else{
Test = false;
break;插入失败则直接跳出循环
}
}
}