/**
* 函数名:executeInsert
* 参数:sqln SQL语句[其中变量名需要@a1...@a2...@a3..以此类推] parameter 对应的参数值,需要用splitc为分隔符
* 执行SQL语句,执行插入语句,并返回插入的ID
* 调用范例executeSQLN("insert into * from test000001 where id = @a1 or id = @a2" , "11" + splitc + "14"); * */
public static int executeInsert(string SQLN, string parameter, int type)
{
SQLN += ";select @@identity;";
SqlConnection objConnection = new SqlConnection(DAL.sqlhelper.connectionStr(type));
if (objConnection.State != ConnectionState.Open)
{ objConnection.Open(); }
SqlCommand objCommand = new SqlCommand();
//new start
objCommand.CommandText = SQLN;
objCommand.Connection = objConnection;
if (parameter.Length !&#
insert into select时如果select没有记录时的返回需要做dbnull.value判断
最新推荐文章于 2021-09-13 14:27:32 发布