Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / ADO.NET / January 2006

Tip: Looking for answers? Try searching our database.

Clarification of an example

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jonefer - 09 Jan 2006 02:01 GMT
The following example from "MURACH's VB.NET database programming with ADO.NET"

seems to be missing something: particularly a type for ('As Vendor'?? )
Maybe someone can help clarify what I need to make this work.

This example demonstrates how to create a VendorDB class with the following
shared function:
'=============================================
Public Shared Function GetVendor(ByVal VendorID as Integer) as Vendor
Dim Vendor as New Vendor()
Dim drVendor as SqlDataReader
Dim conPayables as SqlConnection = GetPayablesConnection()
Dim ssqlCommand = "Select VendorID, VendorName, VendorAddress1, " _
                    & "VendorAddress2, VendorCity, VendorState,
VendorZipCode " _
                    & "From Vendors Where VendorID = @VendorID"
Dim cmdVendors as New SqlCommand(sSqlCommand, conPayables)
cmdVendors.Parameters.Add("@VendorID", VendorID)
conPayables.Open()
drVendor = cmdVendors.ExecuteReader(CommandBehavior.SingleRow)
if drVendor.Read Then
   Vendor.ID = drVendor("VendorID")
   Vendor.Name = drVendor("VendorName")
   Vendor.Address1 = drVendor("VendorAddress1").ToString
   Vendor.Address2 = drVendor("VendorAddress2").ToString
   Vendor.City = drVendor("VendorCity")
   Vendor.State = drVendor("VendorState")
   Vendor.ZipCode = drVendor("VendorZipCode")
Else
   Vendor = Nothing
End if

conPayables.Close()
Return Vendor

End Function
'======================================

I'm stuck because I can't set the function type to 'As Vendor'
It doesn't know what that is??
Where did they get that type... ?

there's no explanation in the text other than this:

The GetVendor method accepts a Vendor ID as an argument and then retrieves
the vendor with that ID.  To do that, the Select statement that retrieves the
vendor includes a parameter for the VendorID column, and the value that's
assigned to the VendorID argument is assigned to that parameter.  Notice that
this method uses a data reader to retrieve the vendor row.  Then, if a row
with the specified value is found, the values in that row are assigned to the
properties of a Vendor object that's declared at the beginning of this
procedure.  Otherwise, Nothing is assigned to the Vendor object.  In either
case, the method passes the Vendor object back as its return value.

thank you for any help at all.
john smith - 09 Jan 2006 02:14 GMT
It looks like a Business Object (a class) they've defined somewhere else
- like what is done in most n-tier enterprise solutions. It's not a
native .net object.
Cor Ligthert [MVP] - 09 Jan 2006 07:39 GMT
Jonefer,

There should be showed something as a class in your book "Vendor".

Something that most of us do mostly with a datatable, however replaces it in
this case.

Cor
Chak - 14 Jan 2006 17:24 GMT
If the Vendor class is in a project different from the one that has the
VendorDB class, you need to add a reference to the other project .

Chak.

> The following example from "MURACH's VB.NET database programming with
> ADO.NET"
[quoted text clipped - 57 lines]
>
> thank you for any help at all.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.