|
-
May 23rd, 2009, 08:25 AM
#1
Thread Starter
Junior Member
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.
-
May 23rd, 2009, 05:14 PM
#2
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"
-
May 23rd, 2009, 06:34 PM
#3
Thread Starter
Junior Member
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:
Imports System.ServiceModel
Imports System.Data
Imports System.Data.OleDb
Imports System.Data.SqlClient
<ServiceContract([Name]:="CustomerPurchase")> _
Public Interface InterfaceViewCustomer
<OperationContract()> _
Function ViewCustomer(ByVal CustNo As String) As String
End Interface
Public Class ViewCustomersService
Implements InterfaceViewCustomer
Public Function ViewCustomer(ByVal CustNo As String) As String Implements InterfaceViewCustomer.ViewCustomer
Dim myDataAdapter As OleDbDataAdapter
Dim myDataSet As New DataSet
Dim DatabaseConnString As New OleDbConnectionStringBuilder
Dim DatabaseConn As New OleDbConnection
With DatabaseConnString
.DataSource = "F:\Project - vb\Databases\CustomerPurchasesDatabase.mdb"
.PersistSecurityInfo = False
.Provider = "Microsoft.Jet.OLEDB.4.0"
End With
Try
DatabaseConn.ConnectionString = DatabaseConnString.ConnectionString
DatabaseConn.Open()
Catch ex As Exception
Return ("Connection Failed")
End Try
myDataAdapter = New OleDbDataAdapter("Select * from CustomerConservatoryPurchases where CustomerNumber = " & CustNo & "", DatabaseConn)
Try
'Fill the DataSet
myDataAdapter.Fill(myDataSet, "CustomerConservatoryPurchases")
' myDataSet.DataSource = myDataSet.Tables("")
Return (myDataSet)
'set the details in the grid
Catch ex As Exception
Return ("sorry, there was error when loading your table")
End Try
End Function
End ClassThanks !
-
May 25th, 2009, 04:41 AM
#4
Hyperactive Member
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.
-
May 25th, 2009, 05:53 AM
#5
Thread Starter
Junior Member
Re: Use the WCF to view a table from an access database
Thanks, ill try to fix it, thank you.
-
May 25th, 2009, 09:10 AM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|