Friday, March 09, 2007 9:12 AM royashbrook

nopatchforstupid #1


stupid

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
public bool CleanUpTable(decimal id)
{
bool bRet = true;
try
{
if (db != null)
{
DbCommand dbCommand = db.GetStoredProcCommand("delete proc");
db.AddInParameter(dbCommand, "@id",DbType.Int32,id);
db.AddOutParameter(dbCommand,"@errorFlag", DbType.Int32,10);

int ret;
db.ExecuteNonQuery(dbCommand);
ret = dbCommand.Parameters["@errorFlag"].Value == DBNull.Value
? 0
: (int) dbCommand.Parameters["@errorFlag"].Value;
if (ret == 0)
{
bRet = false;
}
}
}
catch (SqlException e)
{
Logger.Write(e.Message, "Exception occured while cleaning up table", 1, -99,
TraceEventType.Critical);
bRet = false;
}
catch
{
Logger.Write("Exception", "Exception occured while cleaning up table", 1, -99,
TraceEventType.Critical);
bRet = false;
}
return bRet;
}


not stupid

1
2
3
4
5
6
7
8
9
10
11
12
13
public bool CleanUpTable(decimal id){
try{
using (DbCommand c = db.GetSqlStringCommand(
"delete from talbewhere id= @id")){
db.AddInParameter(c,"@id", DbType.Int32,id);
db.ExecuteNonQuery(c);
return true;
}
}catch (Exception e){
Logger.Write(e.Message, "Exception occured while cleaning up table",1, -99,TraceEventType.Critical);
return false;
}
}

(via don't feed the penguins) Filed under: ,

Comments

No Comments