Creating Data Access Layer - Return My Object But Not All The Fields

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


ADVERTISEMENT

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

Dependent Object Will Not Return Data For Extended Fields In TPT

Jul 22, 2011

I am using TPT modeling and writing the EDMX by hand as our data model is much more complex than the designer can support. My model includes a ProjectObject which has a dependent object name Project. When I query ProjectObject.OfType(Project) using Linq to SQL, I receive back data in all the fields that are inherited from ProjectObject, but no data in the fields that only in Project. I have ran a SQL Server Trace and captured the actual SQL and ran it using SSMS and it returns data there, so I am relatively certain the data is being passed back, but it seems to be getting lost somewhere in EF. Everything appears to be ok in my model, but . . .

SSDL
<EntityContainer Name="Insight_ModelStoreContainer">
<EntitySet Name="Project" EntityType="Insight_Model.Store.Project" store:Type="Views" store:Schema="dbo" store:Name="vw_insight_Project">
<DefiningQuery>
SELECT
[Code] .....

View 1 Replies

Creating A Data Layer - Prototype An Application With A data Layer?

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

VS 2008 Connect A Logic Layer Between Presentation Layer And Data Layer?

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

Sql - Improving Data Access Layer?

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

Where To Put Calls To Data Access Layer?

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

Reading App.config In Data Access Layer?

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

Way To Write The Data Access Layer Faster?

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

Create An Implement Interfaces In The Data Access Layer?

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

Disposing Of Custom Data Access Layer References?

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

Exception Handling In Base Class For Data Access Layer

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

Format Numbers In The Business Lyer Or In The Data Access Layer?

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

TCPClient - Creating Form Fields To Send Data

Jan 4, 2011

I'm using: [URL]. I already have the listener up and running. For the 'client' I'd like to change it to a 'form' program with a text field so i can enter one line of text and then a send button. I know how to drag the field and button over to a form but I'm not sure how to tell the program to use them?

Imports System
Imports System.IO
Imports System.Net
Imports System.Net.Sockets
Imports System.Text
Imports Microsoft.VisualBasic
[Code] .....

View 9 Replies

Populating Object Properties Depending On Fields In A Data Row?

Jun 29, 2010

Let's say I have an employee class with ID, Forename, Surname, Initials and Email Address properties.

At present, you can construct an Employee object by passing a data row which, typically will include all these fields. However, sometimes I only want the ID, Forename and Surname but still want to populate an object.

[Code]...

However obviously if certain fields are not present in the data row, I will have an error. Is there a quick way of populating the object based on the fields that are present within the data row without a) having to have separate subs for each circumstance and b) without having to try / catch (or something similar) around each property? I know other languages have options like this - where if there is no value, it will be another value (i.e. a default).

View 5 Replies

Sql - Unit Testing The Data Access Layer - Testing Update Methods?

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

Access Other Data Fields From Combo Box Data Source?

Nov 4, 2009

I have a combo box with a data source. This box shows one column of a table and allows me to select one item.Next, I have an ordinary text LABEL that I need to put text from another column of the item selected above.I tried to set the data binding field of the label, but this grabs only the first row or data and shows the selected column. That is nice, but I can not figure out how to update the selected selected ROW when the combo box item is changed.In this case the combo box lists a bunch of inventory parts. When I select a specific part, I need the change the text in a label to show the manufacturer. (like a sub-form). This same behavior will be used in several other places, but the relationships can cascade.

View 4 Replies

Creating A Gridview And Gather The Data From Various Functions That Return A Type Of IEnumerable?

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

Access Data Fields Treated As Text When They Are Numbers?

Feb 13, 2012

I have an Access database file, which the application needs to connect only when it needs to run a query. The database has five fields. The first two fields contain numerical values (double). The rest are text values.

Well, I don't have trouble accessing the database file. In fact, I don't have trouble running a query on those three fields containing text values, either. But I have trouble making a query on numerical fields. If I run the following, the application will exhibit a data mismatch error.

'MyConnection As OleDbConnection
'MyAdapter1 As OleDb.OleDbDataAdapter
'nIP is a large number like 3647665152

[Code].....

View 6 Replies

Create Word Form Fields With Memo Fields From Access?

May 27, 2012

I'm trying to create a table in Word using data from a table in Access. There are four fields in the access table that I need. 3 fields are text which I can populate the Word without any issues. However the fourth field is a memo with >255 characters.I'm struggling to come up with the proper code to allow me to populate the Word field with the memo data that has more than 255 characters. The code I have so far is listed below. But when it hits the memo field, it crashes on the line I marked with **. I know it's not text, but I've tried many different field types, but nothing has worked so far.[code]...

View 1 Replies

Failure To Create Data Controls To Access Database Object Reference Not Set To An Instance Of An Object?

May 3, 2011

I was create Access database with Access 2003. I create VB project with Visual Studio 2005 Standard With connection wizzard I create coonect with this Access database, select all tablesI see this database inside Data sources and inside Server explorer Test connection is OK When I drag and drop table from Data sources, Wizzard don't create DataGridView, DataSourceBinding etc .. and I see popup window with mesage: Object reference not set to an instance of an object and then "game over"

View 2 Replies

Asp.net - Use ExecuteSQLCommand And Return Data In A Datatable And Access It?

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

Use ExecuteSQLCommand And Return My Data In A Datatable And Access It?

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

Class - Add A Readonly Property To Layer That Is Calculated Using Some Layer Information?

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

Return Data From An Access Record From User Input?

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

Search Access Database And Return Data To Textbox

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

Return An Object As The Return Value Through A RealProxy Transparent Proxy?

Oct 7, 2010

I'm working up a system where I plan on using RealProxy objects to enable intercepting method calls against a set of objects, handling the call, and then returning appropriate results. This works just find for simple return types like strings or ints, but I can't seem to return objects from the RealProxy.Invoke method. Everything works. I get no errors, but the returned value is always NOTHING, instead of an object.

I've worked up the smallest sample code I could, and have included it below. Essentially, just call RPtest and single step through. The code creates a simple object, RPTestA, with a string field and an object valued field It then retrieves the string

[Code]...

View 1 Replies

Creating A Button To Add Data From Textfields On Form In Access Db

Jun 5, 2011

I am creating a small program which has a few texboxes which i want to saved in a access database.My problem is i have no clue what code belongs to such button.I have added the database to my datasources, and linked the fields from the database to the textboxes.But thats all i got so far,.Being searching around the net for a few days to figure this out, but no luck.in my access db i got the fields firstname, surename, address1, address2, postcode, phone, email.Each are linked to their matching textbox on the form.

View 2 Replies

SQL Data Access: VB2008 / VB2010 - WinForms - Create A Datasourse And Drag / Drop Fields Or Tables On A Form To Create A Grid

Oct 22, 2010

I have used VB (versions 2 - 6) through many years; however, I am crash-course training myself into the VB2008 / VB2010 world kicking a screaming. I would like suggestions as to what SQL database access method should I focus more on in my learning process without making me feel that I'm a million years behind. I know I have WinForms where I can create a datasourse and drag / drop fields or tables on a form to create a grid (not really what I'm looking for).

My trouble isn't so much designing the form but in how I access the database. Theres XML, LINQ to SQL, ADO.NET, and many other methods. Not only do I need to grasp these methods quickly but I also need to know what type of projects I should create. What I mean is...I was thinking that I would design a WinForm app; however, I see that there are WPF apps and others to chose from. This is getting deep. I know it depends on the project that I'm working on. My plans are to write an app based off of either an SQL Express 2008 or SQL Server 2008 database. This first app will be standalone for now but may later become multi-user. I know I'm far behind on my learning curve coming from VB6. I have read a bit on VB2005 / 2008 / 2010. I own
both VB2008 and VB2010. I use VB2008 at work. I know ADO.NET is still alive but by what I read online, it's a dying method and is only kept for backward compatibility. XML and LINQ to SQL and other methods are all pretty new to me.

View 1 Replies

Creating New DLL's - "the Call To The Server.CreateObject Falied While Cheking Permissions. Access Is Denied To This Object"

Jun 21, 2010

I am getting this error saying "the call to the server.CreateObject falied while cheking permissions. Access is denied to this object".I get this error every time I create a new DLL after compiling my VB6 code and drop it in the component services.i am using these DLL's for the web application i am working on. Is this a DLL registration issue, or is this because the DLL is not being generated correctly. What are your thoughts on this? i have attached the error message for reference

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved