Results 1 to 6 of 6

Thread: Use the WCF to view a table from an access database

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2009
    Posts
    29

    Use the WCF to view a table from an access database

    Hey everyone

    I have tried to use the WCF to return a table from Microsoft Access and then return the details to the form and display in a data grid view.

    Any suggestions, mine doesn't work. Thanks.
    RACHEL.

  2. #2
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Use the WCF to view a table from an access database

    Post the code you've got so far and tell us in what way it "doesnt work"
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  3. #3

    Thread Starter
    Junior Member
    Join Date
    Apr 2009
    Posts
    29

    Re: Use the WCF to view a table from an access database

    here is the service code. When i set the values into the dataset nothing gets sent back to the form. Everything else works. Thanks.

    vb Code:
    1. Imports System.ServiceModel
    2. Imports System.Data
    3. Imports System.Data.OleDb
    4. Imports System.Data.SqlClient
    5.  
    6. <ServiceContract([Name]:="CustomerPurchase")> _
    7. Public Interface InterfaceViewCustomer
    8.     <OperationContract()> _
    9. Function ViewCustomer(ByVal CustNo As String) As String
    10.  
    11.  
    12. End Interface
    13.  
    14.  
    15. Public Class ViewCustomersService
    16.     Implements InterfaceViewCustomer
    17.  
    18.     Public Function ViewCustomer(ByVal CustNo As String) As String Implements InterfaceViewCustomer.ViewCustomer
    19.         Dim myDataAdapter As OleDbDataAdapter
    20.         Dim myDataSet As New DataSet
    21.  
    22.         Dim DatabaseConnString As New OleDbConnectionStringBuilder
    23.         Dim DatabaseConn As New OleDbConnection
    24.  
    25.         With DatabaseConnString
    26.             .DataSource = "F:\Project - vb\Databases\CustomerPurchasesDatabase.mdb"
    27.             .PersistSecurityInfo = False
    28.             .Provider = "Microsoft.Jet.OLEDB.4.0"
    29.         End With
    30.         Try
    31.             DatabaseConn.ConnectionString = DatabaseConnString.ConnectionString
    32.             DatabaseConn.Open()
    33.         Catch ex As Exception
    34.             Return ("Connection Failed")
    35.         End Try
    36.  
    37.         myDataAdapter = New OleDbDataAdapter("Select * from CustomerConservatoryPurchases where CustomerNumber = " & CustNo & "", DatabaseConn)
    38.  
    39.  
    40.         Try
    41.             'Fill the DataSet
    42.             myDataAdapter.Fill(myDataSet, "CustomerConservatoryPurchases")
    43.  
    44.  
    45.  
    46.             '  myDataSet.DataSource = myDataSet.Tables("")
    47.  
    48.  
    49.  
    50.  
    51.             Return (myDataSet)
    52.  
    53.  
    54.  
    55.  
    56.  
    57.  
    58.             'set the details in the grid
    59.         Catch ex As Exception
    60.             Return ("sorry, there was error when loading your table")
    61.         End Try
    62.  
    63.  
    64.  
    65.  
    66.     End Function
    67.  
    68. End ClassThanks !

  4. #4
    Hyperactive Member
    Join Date
    Mar 2008
    Location
    Zeist, The Netherlands
    Posts
    266

    Re: Use the WCF to view a table from an access database

    First thing to come to mind is that you declare the result of the ViewCustomer function as string, and the try to return a DataSet. It should throw an error I think.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Apr 2009
    Posts
    29

    Re: Use the WCF to view a table from an access database

    Thanks, ill try to fix it, thank you.

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Use the WCF to view a table from an access database

    Don't be afraid to return datasets or custom class types from your WCF methods; it'll work as long as it's serializable. To minimize overhead, you should consider returning a List<YourClass> rather than dataset, or at least return a datatable.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width