What Return Type To Use In Data Access Layer
Mar 1, 2010
Im writing a data access layer for my application.There are several functions that need to return a list of items like Employee Name, and EmployeeID so it can be bound to a dropdownlist.What would be the proper datatype to return, a Dictionary?The lists only contain 2 columns, a name and id.
View 5 Replies
ADVERTISEMENT
Jun 21, 2010
I'm creating my Data Access Layer and I want to return my object but not all the fields so this is the code i'm using
CODE:
I then call this method in the Business Logic Layer
CODE:
lastly I try to call in in my user interface and bind it to a DataGridView
CODE:
But I keep getting this error: Unable to cast object of type 'System.Data.Linq.DataQuery`1[VB$AnonymousType_0`3[System.String,System.String,System.String]]' to type 'System.Collections.Generic.IEnumerable`1[PP_DAL.DCProposal]'.
View 2 Replies
Feb 7, 2011
I am generally following this tutorial, the main differences being I'm using 2008 R2 Express and Windows Forms, he is using 2005 & ASP.NET Web Site:'m building a minimalist Windows Form project for learning purposes. So I'm using a 1-table database with 2 columns, ContactID & Name. I added a dataset file, 'ContactsDataSet.xsd' to my project and added a single minimalist table adapter with just a fill() & getdata() method.Then I added a DataGridView control and connected it to the ContactsDataSet to confirm it was working and that worked fine. I ran it and it filled up with data as expected. Everything up to this point was auto-generated code.
View 4 Replies
May 22, 2009
I am putting some heavy though into re-writing the data access layer in my software(If you could even call it that). This was really my first project that uses, and things were done in an improper manner. In my project all of the data that is being pulled is being stored in an arraylist. some of the data is converted from the arraylist into an typed object, before being put backinto an arraylist.Also, there is no central set of queries in the application.This means that some queries are copy and pasted, which I want to eliminate as well.This application has some custom objects that are very standard to the application, and some queries that are very standard to those objects.
View 5 Replies
Feb 20, 2009
I am implementing a Data Access Layer (DAL), which is basically a set of classes with (VB.NET) Shared functions to actually execute the database (CRUD) calls. I am trying to figure out the best place to place the calls to the DAL within the class hierarchy. Let me give an example.Suppose I have a class Customer, with only standard ID, Name, Address1, etc. properties and maybe an overridden ToString function or so. I also have a DAL class with Shared methods, such as:[code]Would this be "cleaner" OOP? Or is it acceptable practice to let the presentation call the Dal, passing the business objects like my previous example:[code]
View 3 Replies
Mar 23, 2010
Im experiencing some problems while attempting to read a connection string from an App.config file in my Data Access Layer.I added the App.Config to the DAL Class Library, and added my connection string to the connectionStrings section but when I try to read it from my DAL its Returing Nothing.
[Code]...
View 4 Replies
Oct 1, 2009
One of the time consuming factors of writing the DAL is adding and assigning paramters of teh stored procedure if ther are more than 10 parameters and must link more than 3 tables this process will take a horrible amount of time..
View 10 Replies
Jul 26, 2009
I am trying to prototype an application with a data layer on my computer at home using Visual Basic 2008 express edition with SQL Server Compact 3.5. My production situation at work is SQL Server 2000 and I am using Visual Basic 2005 professional for development.I am trying to write the code to create a seperate data layer. Here is my code. First the data layer:
Imports
System.Data
Imports[code].....
My Problem is that the data does not show up in the text boxes.
View 1 Replies
Jan 15, 2010
I typically dont create interfaces unless i have to, however in my current application i have to create interfaces in the Data access layer. I'm a in a minor confusion that hwo do i create those interfaces more how to implement them: the following code might make things clear:I have the following class and interface in the data access namespace
[code="vb"]Imports ConsoleApplication8.BusinessLayerImports ConsoleApplication8.DataAccessLayerImports System.DataImports System
Namespace DataAccessLayer
Public Class CountryGateway Implements ICountryGateway
[code]....
1. Is this way implement the interface in the data access layer? (in this case the class CountryGateway access the database.)
2. I have been told that we should create interfaces than abstract classes espcially in the data access layer, is there a particular reason for this?
View 9 Replies
Oct 1, 2010
Our application uses a custom DataAccessLayer class almost exclusively, and within that we do use Data Access Application Block (currently version 2). We are getting the infamous "GetOrdinal" error sporadically. We are not using out-of-method connections. We are using DAAB version 2. Below is a typical example of our DAL methods:
Public Function MyDALMethod(ByVal Param1 As Integer, ByVal Param2 As Integer) As System.Data.IDataReader
Dim db As Database = DatabaseFactory.CreateDatabase()
[Code].....
My main question is should these DAL references be disposed somehow? It's a custom class written in VB.NET, so it doesn't implement IDisposable so I'm not sure if there's anything to be done or not, but we do have errors and issues (like the GetOrdinal problem) which seem to be load-related, and I'm wondering if this is part of the problem.
View 1 Replies
Mar 14, 2010
I would like to build a base class for my SQL Data Access Layer. I have most of it based out, but have a question about how to handle errors within the base class. I have a method for ExecuteNonQuery, ExecuteReader, ect...
[Code]...
View 18 Replies
Aug 25, 2009
IN my daat access layer, the stored procedure returns value of the format "CCT1". But i need to format that value to "CCT00001". Should i do this formatting in the data access layer or in the business layer?
View 4 Replies
Dec 27, 2010
I'v designed a ms access database table with one field having Datetime datatype. I can Insert data into it from vb.net front end by trns_dt DateTime.Now.DateBut when I fetch records from the tableand assign the dataset datasource as da, it shows datatype mismatch error.
daleDbDataAdapter("SelectDaily_Transactiondtp_from_dt.value dtp_To.value con)
dsDataSet
[code].....
View 2 Replies
May 15, 2009
I'm looking into adding some unit tests for some classes in my data access layer and I'm looking at an update routine that has no return value.It simply updates a row based on the id you provide at whichever column name you provide.Inside of this method, we collect the parameters and pass them to a helper routine which calls the stored procedure to update the table.Is there a recommended approach for how to do unit testing in such a scenario?
View 4 Replies
Feb 28, 2012
I am creating a gridview and need to gather the data from various functions that return a type of IEnumerable. I've created gridviews using a dataset as a datasource, but how does one use multiple data sources(of IEnumerable) to populate one gridview? Like how do you combine all that into one dataset?
View 1 Replies
Sep 15, 2010
This is what I'm trying...
Dim myCommand as SqlCommand
Dim myTable as New xsdObject.ObjectDataTable
myCommand = DataAccess.GetSQLCommand( "MyStoredProc", _
[code]....
'How to access my data ?
View 1 Replies
Nov 4, 2011
Use ExecuteSQLCommand and return my data in a datatable and access it? This is what I'm trying.[code]...
View 2 Replies
Nov 30, 2010
I am working in VB.NET defining my own classes. I have 5 classes, Policy, Coverage, CoverageCollection, Layer, and LayerCollection. Policy has a bunch of data items, one of which is of type CoverageCollection. Coverage has a bunch of data items, one of which is of type LayerCollection.
Policy
private id as Long
private name as String[code].....
Then I do like "dim p as Policy". So, iIn order to get to properties on a Layer, I reference it like p.cov(0).lyr(0).face. What I am trying to do is add a readonly property to Layer that is calculated using some Layer information but also using something from Coverage (or even Policy). I can take this in as a parameter to the property, but I think there should be a way to get at Coverage/Policy information since I am "under" it already. Is there a way to do this?
View 1 Replies
Feb 17, 2011
It's been a good few years since I dabbled in VB and I'm very very rusty so any help would be great! What I'm looking to do is search an access database with user input and display the relevant record.I have a single table set up in an access database called school_info with the following fields and data:
Tres________DfE________Name_________Type
001________1234________School 1________Primary
002________4321________School 2________Secondary
[code]...
I've linked the database to my new project, connected the database and added the 4 fields to my form. When I run it, the data shows in the boxes fine.The Tres and DfE fields are show in text boxes on the VB form, and the school and Type are show in labels. What I really want to do is be able to manually type in either a Tres or DfE number into the relevant text field and have the other labels auto populate with the relevant data that's stored in the database table.
View 9 Replies
Apr 22, 2011
I've created a basic search form. I have a textbox with a search button and an Access Database as the backend. I have also added it as a new datasource. What I'm looking to do is grab the search string from one textbox and return the data to another textboxt. I have a table called "VehicleInfo" and I want to search the field in my table called "VehicleID" and return the vehicleID I searched for into another textbox. I'm really new to VB. I understand databases and basic code structure, I just don't have a good grasp yet on how these two work together.
Public Class frmMain
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'Garage_ServiceDataSet.Service' table. You can move, or remove it, as needed.
Me.ServiceTableAdapter.Fill(Me.Garage_ServiceDataSet.Service)
[Code] .....
View 7 Replies
Nov 23, 2009
I have a copy function that I'd like to override in subclasses to return the type of the subclass. Here are my interfaces:
Public Interface IBase(Of T)
Function Copy() As T
End Interface
[Code]....
View 4 Replies
Apr 22, 2010
I have a delegate and its event in C# as below:
public delegate UsernameCredentials UsernameRequiredEventHandler( object sender, string endpoint );
public event UsernameRequiredEventHandler UsernameRequired;
On Converting the above code in VB.Net as follow :
Public Delegate Function UsernameRequiredEventHandler(ByVal sender As Object, ByVal endpoint As String) As UsernameCredentials
Public Event UsernameRequired As UsernameRequiredEventHandler
I am getting error on the above line saying that "Events cannot be declared with a delegate type that has a return type".I understand that this is not supported in VB.Net.
View 3 Replies
Jul 25, 2011
I've never used a List(Of) before and I'm not sure how to pass it to the Data Layer of my application. The ColResCategory is a property within the Business Layer (See below) and it needs to be passed to the Data Layer. ReplaceResCategory (See 2nd Code view) is another class file within my Business Layer and the ColResCategory references it.
Public Property ColResCategory() As List(Of ReplaceResCategory)
Get
If IsNothing(mColResCategory) Then
mColResCategory = New List(Of ReplaceResCategory)
End If
Return mColResCategory
[Code] .....
View 5 Replies
Feb 19, 2011
I'm creating a Data Layer for a Web Application and in one of my functions, I need to pass in a Structure full of Customer info. This Data Layer is essentially a DLL. My problem is that I'm not sure how to do this.Below is my code and what I want to do.
[Code]...
View 5 Replies
Oct 10, 2010
i try to update the table but not sucessful. In access database the following fields with datatype as under;
Parameters=text
Value=Number
Units=text
[code].....
View 23 Replies
May 28, 2009
Need a SQL Server "SQLClient" (VB) Data Layer Class?
View 2 Replies
Feb 27, 2009
We have data that's updated nightly in a database residing in the same instance as my app's database. So to save on database calls, I want to cache this static-for-the-day data into a List(Of MyObject). From a theory point of view, should this cached List(Of ) be cached in the presentation layer code, via a global variable? Should it be in a global variable in the .DLL?I'm thinking in the .DLL, because I created a service layer, which is exposed publicly to the GUI and makes calls to the data access layer inside the .DLL:
Public Shared Function Search(ByVal criteria As Core.Other.Customer) As List(Of Core.Other.Customer)
' TODO: Check the customer cache to see if it has been populated yet. If not, populate it.
If 1 = 1 Then
[code]....
View 3 Replies
Feb 15, 2012
I am using VS 2008, asp.net and VB coding.Using Grid View, How can I access the data of the selected row if the column type is check box?The following line is working fine with text, date, number,lbltest.Text = GridViewRVs.SelectedRow.Cells(7).Text but the problem is that I need to access a checkbox..
View 1 Replies
Mar 4, 2010
I'm trying to update ms access data using vb.net and here's my code:
updateuserclass.vb
Public Class UpdateUser
Dim bankai As New Updater
[Code]...
What might be wrong in here?I set it all to string, is the primary key usernum not a string.
View 2 Replies
Jun 12, 2011
What data type could I use in my access database that can hold very long texts. By default, each cell in Access tables can only contain up to 255 characters. Is there any way to extend this to any length I want?
View 4 Replies