Click here to Skip to main content
16,016,460 members
Home / Discussions / C#
   

C#

 
AnswerRe: Problem in connection string Pin
Ennis Ray Lynch, Jr.27-May-08 9:09
Ennis Ray Lynch, Jr.27-May-08 9:09 
AnswerRe: Problem in connection string Pin
Shuaib wasif khan27-May-08 9:24
Shuaib wasif khan27-May-08 9:24 
QuestionPicturebox problem Pin
Joplinazz27-May-08 8:10
Joplinazz27-May-08 8:10 
AnswerRe: Picturebox problem Pin
led mike27-May-08 8:39
led mike27-May-08 8:39 
AnswerRe: Picturebox problem Pin
Anthony Mushrow27-May-08 8:41
professionalAnthony Mushrow27-May-08 8:41 
GeneralRe: Picturebox problem Pin
Joplinazz27-May-08 8:47
Joplinazz27-May-08 8:47 
AnswerRe: Picturebox problem Pin
MarkB77727-May-08 14:07
MarkB77727-May-08 14:07 
QuestionUsing static ADO methods in the Data Layer ADO class. Pin
Steve Holdorf27-May-08 6:01
Steve Holdorf27-May-08 6:01 
I wanted to put some simple example code here to show how I am doing Data I/O between the BLL and the DL. Any comments would be great!

Data Layer DAO object:

public class CMItemDAO
{
public CMItemDAO()
{
//
// TODO: Add constructor logic here
//
}

public static IDataReader GetItems(int quantity, ItemManager.Item type)
{
string itemType = (type == ItemManager.Item.Document ? "SW" : "DOC");

String sSql = "SELECT CMLib_Key, CM_Number, Item_Name ";
sSql += "FROM ccdb.cclib WHERE Item_Type = :pITEMTYPE AND ROWNUM <= 10";

Database db = DatabaseFactory.CreateDatabase();

UserDBLogon(db, "xxxxxxxxx@xxxxxxxx.xxx", "WNhc(#111111111");

DbCommand cmd = db.GetSqlStringCommand(sSql);
db.AddInParameter(cmd, "pITEMTYPE", DbType.String, itemType);
return db.ExecuteReader(cmd);
}

------------How this is being called from the Business Layer:

public class ItemManager
{

public enum Item
{
Document,
Software
}

public ItemManager()
{
//
// TODO: Add constructor logic here
//
}

public static List<ICMItem> GetItems(int quantity, Item type)
{
Cache listCache = HttpRuntime.Cache;

List<ICMItem> list = new List<ICMItem>();

ICMItem iCMItem;

if (HttpRuntime.Cache["Item" + type.ToString()] != null &&
(HttpRuntime.Cache["Item" + type.ToString()] as List<ICMItem>).Count <= quantity)
{
list = ((HttpRuntime.Cache.Get("Item" + type.ToString()))) as List<ICMItem>;
list.RemoveRange(quantity, (list.Count - quantity));
}
else
{

using (IDataReader reader = CMItemDAO.GetItems(quantity, type))
{
while (reader.Read())
{
if (type == Item.Document)
iCMItem = new Document() as Document;
else
iCMItem = new Software();

iCMItem.CMLibraryKey = reader.GetInt32(0);
iCMItem.CMNumber = (string)reader[1];
if (reader.GetValue(2) != DBNull.Value)
iCMItem.ItemName = (string)reader.GetValue(2);
else
iCMItem.ItemName = "";

list.Add(iCMItem);
}
}
HttpRuntime.Cache.Insert("Item" + type.ToString(), list);
}

return list;
}

I hope this is not too much simple example code; however, any comments on how I am doing things would be great!

Thanks,


Steve
AnswerRe: Using static ADO methods in the Data Layer ADO class. Pin
N a v a n e e t h27-May-08 6:23
N a v a n e e t h27-May-08 6:23 
Generalecommerce -pay pal Pin
uniqueanurag27-May-08 4:44
uniqueanurag27-May-08 4:44 
GeneralRe: ecommerce -pay pal Pin
Judah Gabriel Himango27-May-08 6:37
sponsorJudah Gabriel Himango27-May-08 6:37 
GeneralRe: ecommerce -pay pal Pin
Krazy Programmer27-May-08 7:36
Krazy Programmer27-May-08 7:36 
GeneralRe: ecommerce -pay pal Pin
Ennis Ray Lynch, Jr.27-May-08 9:10
Ennis Ray Lynch, Jr.27-May-08 9:10 
QuestionDispose off Notify Icon in Console Application.. Pin
ptr2void27-May-08 4:07
ptr2void27-May-08 4:07 
AnswerRe: Dispose off Notify Icon in Console Application.. Pin
Anthony Mushrow27-May-08 4:32
professionalAnthony Mushrow27-May-08 4:32 
GeneralRe: Dispose off Notify Icon in Console Application.. Pin
leppie27-May-08 5:48
leppie27-May-08 5:48 
GeneralRe: Dispose off Notify Icon in Console Application.. Pin
Anthony Mushrow27-May-08 5:56
professionalAnthony Mushrow27-May-08 5:56 
AnswerRe: Dispose off Notify Icon in Console Application.. Pin
leppie27-May-08 5:46
leppie27-May-08 5:46 
JokeRe: Dispose off Notify Icon in Console Application.. Pin
Anthony Mushrow27-May-08 5:57
professionalAnthony Mushrow27-May-08 5:57 
GeneralRe: Dispose off Notify Icon in Console Application.. Pin
leppie27-May-08 6:26
leppie27-May-08 6:26 
Questionforeach Dictionary Pin
George_George27-May-08 3:56
George_George27-May-08 3:56 
AnswerRe: foreach Dictionary Pin
buchstaben27-May-08 4:01
buchstaben27-May-08 4:01 
GeneralRe: foreach Dictionary Pin
George_George27-May-08 23:45
George_George27-May-08 23:45 
AnswerRe: foreach Dictionary Pin
Guffa27-May-08 4:24
Guffa27-May-08 4:24 
GeneralRe: foreach Dictionary Pin
George_George27-May-08 23:44
George_George27-May-08 23:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.