/// <Summary>
/// Demonstrate data access, cache, and logging (parameterized SQL statement)
/// </Summary>
/// <Param name = "Param"> </param>
/// <Returns> </returns>
Public static string db_cache_exception (int param)
{
Try
{
String cachename = "cahcename _" + Param. tostring ();
Object o = cacheman. getdata (cacheman. highcache, cachename );
If (O = NULL)
{
Database DB = dB. reader; // read-only account
Dbcommand cmd = dB. getsqlstringcommand ("select count (*) from tablename where Param = @ Param ");
DB. addinparameter (CMD, "@ Param", dbtype. int32, Param );
O = dB. executescalar (CMD );
If (o! = NULL)
Cacheman. gencache (cacheman. highcache, 720, cachename, cacheman. cachepriority. High, O );
Else
Return "";
}
Return O. tostring ();
}
Catch (exception ex)
{
Handleexception. logexception (Ex );
Return "";
}
}
Public static int writebyparam (string a, string B)
{
Database DB = dB. Writer;
// Read/write account
Dbcommand cmd = dB. getsqlstringcommand ("insert into tablename (a, B) value (@ A, @ B )");
DB. addinparameter (CMD, "@ A", dbtype. String, );
DB. addinparameter (CMD, "@ B", dbtype. String, B );
Return dB. executenonquery (CMD );
}