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.
Printable View
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.
Post the code you've got so far and tell us in what way it "doesnt work"
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 !
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.
Thanks, ill try to fix it, thank you.
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.