473,398 Members | 2,212 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,398 software developers and data experts.

taking data from a database and assigning to variable in Business layer

143 100+
I have a C# project that uses datasets to pull data out of a SQL server database. I have 3 controls on the windows form that are bound to the dataset, but I have a 4th attribute that I want sent to a variable in the business layer.

I could set the variable to the text property of a textbox and make the textbox invisible, but that seems like cheating. How do I take that attribute from the dataset and assign it to a string variable?
Aug 13 '07 #1
2 1213
nateraaaa
663 Expert 512MB
I have a C# project that uses datasets to pull data out of a SQL server database. I have 3 controls on the windows form that are bound to the dataset, but I have a 4th attribute that I want sent to a variable in the business layer.

I could set the variable to the text property of a textbox and make the textbox invisible, but that seems like cheating. How do I take that attribute from the dataset and assign it to a string variable?
I would recommend creating an accessor (getting/setter) in your Business layer. Then when you retrieve your dataset values assign this variable to the value of the row/column in your dataset.

Business Layer
Expand|Select|Wrap|Line Numbers
  1. namespace buslayer
  2. private string _variable;
  3. public string Variable()
  4. {
  5.  set {_variable = value;}
  6. }
C# project that pulls data from database
Expand|Select|Wrap|Line Numbers
  1. private string attribute4 = "";
  2. attribute4 = dataset.Tables[0].Rows[0]["ColumnName"].ToString();
  3. if(attribute4 != null && attribute4 != "")
  4. {
  5. buslayer.Variable = attribute4.ToString();
  6. }
By making the variable public in your business layer you should have the ability to assign its value from the dataset.

Nathan
Aug 13 '07 #2
teddarr
143 100+
Thanks, I'll give that a try.
Aug 14 '07 #3

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

Similar topics

1
by: Johann Blake | last post by:
I am looking for a good solution on how to implement data access in an application so that there is a clean separation between the data access layer, the business layer and the GUI layer. I am...
2
by: headware | last post by:
I'm relatively new to ASP.NET and ADO.NET, but I have a basic design question regarding the use of web services and APS.NET applications. Right now we have an application that uses web services to...
5
by: AAJ | last post by:
Hi all FIRST THE BORING BITS....... I normally use a Database layer, a Business layer and a GUI layer. The GUI uses an Object data source to bind to the Business layer which in turn binds...
17
Motoma
by: Motoma | last post by:
This article is cross posted from my personal blog. You can find the original article, in all its splendor, at http://motomastyle.com/creating-a-mysql-data-abstraction-layer-in-php/. Introduction:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.