473,320 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

3 n-tier architecture using DataReader

1
Hi everyone!

How can I use DataReader() with 3-tier architecture when getting data?For example;

Data Layer:
Expand|Select|Wrap|Line Numbers
  1. public void DataLoad(int id)
  2. {
  3.   SqlConnection conn = new SqlConnection(DB.connStr);
  4.   SqlCommand cmd = new SqlCommand("select * from page where id = @id", conn);
  5.   cmd.Parameters.AddWithValue("@id",id);
  6.   conn.Open();
  7.   SqlDataReader dr = cmd.ExecuteReader();
  8.   try
  9.   {
  10.     while(dr.Read())
  11.     {
  12.       //?? how i set data to a standard tool? (label,literal,etc..)
  13.     } 
  14.   }
  15.   catch
  16.   {
  17.     throw;
  18.   }
  19.   finally
  20.   {
  21.     conn.Close();
  22.   }
  23. }
Sep 23 '11 #1
1 3642
Frinavale
9,735 Expert Mod 8TB
Please check out the article about How To Use A Database In Your Program. There are examples on how to do this in the article.

-Frinny
Sep 23 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Red | last post by:
How to read cml from datareader thanks
2
by: Mattyw | last post by:
Hi I have a sqlcommand that returns all the rows in a column and then pass that to a datareader. I am new to VS.Net and so far I can only return the first row in the first column using ...
0
by: pedaammulu | last post by:
Hi, I have put up a page which can help you to understand the workings of how to access SQL data using VB.Net. http://www.vkinfotek.com/datareader.html All info on the page and site is to...
1
by: nasirmajor | last post by:
Dear All, im fetching record from database using datareader, and is displaying them in the textboxes. when user change the text fields and then presses the update button the record should be...
3
by: Richard Coltrane | last post by:
Hello Im reading this article about the Gridview: http://msdn.microsoft.com/msdnmag/issues/04/08/GridView/ Whilst I realise that im not forced to use their methods I do find it confusing...
2
by: cschuman | last post by:
Currently there are 60+ web applications at my shop. The applications have similar functionality just different parameters. We are about to go through a reskinning process. I would like to...
0
by: Nagarajk | last post by:
Hi all, Can any one tell me how to implement 3-tier architecture using asp.net and it should work irrespective of database.. Pls let me know ur suggestions. Regards Nagaraj.
3
by: dianaj86 | last post by:
I have multiple dropdownlists each one filled with values from a specific column in the table. Also I have multiple textboxes corresponding to dropdownlists. For example, when I select an item from...
0
by: Selun | last post by:
Hi all, First of all im not sure if this is the correct section to ask this. Im using C# .NET I m trying to populate a gridview using datareader with the following code protected void...
1
by: lenniekuah | last post by:
Hullo Awesome Friends, WINDOW Based Application using VBNET2008, DataReader and TreeView Control Nodes I need your help, Please help me. I am using TreeView controls and having problem...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.