飞凡团队

类管理-1

sql语句:

insert into table () values ()

update table set a= @a,b= @b where ID = @ID

delete from table where Id = @Id

 

执行命令

public  static int ExecuteNonQuerty(DbCommand command)

{

int a = -1;

try

{

command.connection.Open();

a =  command.ExecuteNonQuery():

}

catch (Exception Ex)

{

throw Ex.ToString();

}

finally

{

command.connection.Close();

}

return a;

}

 

判断是否执行成功

public static bool update(DbCommand command)

{

int result = -1;

try

{

result  =  DB.ExecuteNonQuery(command)

}

catch

{

}

return (result!=-1);

}

 

posted on 2010-04-07 09:59  飞凡团队  阅读(138)  评论(0)    收藏  举报