Quantcast
Channel: VBForums - WPF, WCF, WF
Viewing all articles
Browse latest Browse all 256

updating database through WCF

$
0
0
Hi, I'm brand new to WCF and have followed the MSDN sample of how to load a datagridview with data in a Tier'ed architecture using a WCF service.

The walk through is missing the "how to update your database" though so I set out on my own to try and figure it out. Read allot an failed alot.

I am building winform app that I want in a tier architecture so therefore using the WCF. Beyond that I get confused.

Here's what I think should work but doesn't. I get a error "(413) Request Entity Too Large" I have read about increasing the Maxmessage size, which I did increase to 200000000.

The following is in my Presentation Layer and the Load event does work, my datagridview does show my data.

Code:

Public Class Form1

    Dim svchost As New ServiceReference1.Service1Client
    Dim OneData As DataEntity_Tier.OneDataDataSet

    Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Try
            Me.Validate()
            Me.IDStaffBindingSource.EndEdit()
            svchost.UpdateStaffTable(OneData)
        Catch ex As Exception

        End Try

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        OneDataDataSet.IDStaff.Merge(svchost.GetStaff)
    End Sub
End Class

next is code in my IService1 file

Code:

' NOTE: You can use the "Rename" command on the context menu to change the interface name "IService1" in both code and config file together.
<ServiceContract()>
Public Interface IService1

    <OperationContract()>
    Function GetData(ByVal value As Integer) As String

    <OperationContract()>
    Function GetDataUsingDataContract(ByVal composite As CompositeType) As CompositeType

    ' TODO: Add your service operations here

    <OperationContract()>
    Function GetStaff() As DataEntity_Tier.OneDataDataSet.IDStaffDataTable

    <OperationContract()>
    Sub UpdateStaffTable(ByVal ORds As DataEntity_Tier.OneDataDataSet)

End Interface

' Use a data contract as illustrated in the sample below to add composite types to service operations

<DataContract()>
Public Class CompositeType

    <DataMember()>
    Public Property BoolValue() As Boolean

    <DataMember()>
    Public Property StringValue() As String

End Class

And finally the code in Service1.vb

Code:

' NOTE: You can use the "Rename" command on the context menu to change the class name "Service1" in both code and config file together.
Public Class Service1
    Implements IService1

    Public Function GetData(ByVal value As Integer) As String Implements IService1.GetData
        Return String.Format("You entered: {0}", value)
    End Function

    Public Function GetDataUsingDataContract(ByVal composite As CompositeType) As CompositeType Implements IService1.GetDataUsingDataContract
        If composite Is Nothing Then
            Throw New ArgumentNullException("composite")
        End If
        If composite.BoolValue Then
            composite.StringValue &= "Suffix"
        End If
        Return composite
    End Function

    Public Function GetStaff() As DataEntity_Tier.OneDataDataSet.IDStaffDataTable Implements IService1.GetStaff

        Dim StaffTableAdapter As New DataAccess_Tier.OneDataDataSetTableAdapters.IDStaffTableAdapter

        Return StaffTableAdapter.GetStaff()

    End Function

    Public Sub UpdateStaffTable(ByVal ORds As DataEntity_Tier.OneDataDataSet) Implements IService1.UpdateStaffTable

        Dim ORdata As New DataEntity_Tier.OneDataDataSet
        Dim da As DataAccess_Tier.OneDataDataSetTableAdapters.TableAdapterManager
        da = New DataAccess_Tier.OneDataDataSetTableAdapters.TableAdapterManager

        da.UpdateAll(ORds)

    End Sub

End Class

So I think the only relevant information is in the last method of Service1.vb.

So does anyone know what could be going wrong. I have a suspicion that WCF cannot handle passing a dataset but I'm brand new to this so obviously I could be very wrong.

Thanks for any help in advance.

Viewing all articles
Browse latest Browse all 256

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>