locked
cant connect DB RRS feed

  • Question

  • I have a WCF sample app that simply display a string and updates a DB.

    http://www.mymrt.net/testwcf/testwcf.Web/testwcfTestPage.aspx


    It works on my pc but on the host server it doesnt update the DB?

    I dont get an error as when i click the button a value in the DB is incrmented . IT does this but not when i run from the host?

    works on my pc. I upload the xap , the dll and service refernce files and for some reason no DB field update and the same DB is used?

    I have crossdomain and the other cross..policy.xml file


    <OperationContract()> _
        Public Function GetSurname() As String
            Return "Sheridan"
        End Function

        <OperationContract()> _
    Public Sub updatedataSin(ByVal myid As String)
            Dim db2 As New testwcf.Web.DataClasses1DataContext
            Dim temp As result
            Dim mylist As New List(Of result)



            Dim myresults = (From p In db2.results _
                            Where p.id = myid _
                            Select p)

            If myresults.Count > 0 Then 'only bother if the user name exists which it will
                For Each p As result In myresults
                    p.sin = p.sin + 1


                Next
                db2.SubmitChanges()


            End If


        End Sub

    End Class


    Private Sub btnGetSurname_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnGetSurname.Click
            Dim uri As New Uri(Application.Current.Host.Source, "../person1.svc")
            Dim client As New testwcf.ServiceReference1.person1Client("CustomBinding_person1", uri.AbsoluteUri)
            '  Dim uri2 As New Uri(Application.Current.Host.Source, "../person1.svc")
            '  Dim client2 As New testwcf.ServiceReference1.person1Client("CustomBinding_person1", uri.AbsoluteUri)
            Dim myid As String

            ' Dim webservice2 As New trigB.ServiceReference1.Service1Client
          
            '   Dim client As New testwcf.ServiceReference1.person1Client

            '  AddHandler client.GetSurnameCompleted, Function(s, args) AnonymousMethod1(s, args)
            ' client.GetSurnameAsync()
            AddHandler client.GetSurnameCompleted, AddressOf AnonymousMethod1
            client.GetSurnameAsync()

            myid = "01"
            client.updatedataSinAsync(myid)
        End Sub

        Private Function AnonymousMethod1(ByVal s As Object, ByVal args As testwcf.ServiceReference1.GetSurnameCompletedEventArgs) As Boolean
            txtSurname.Text = args.Result
            Return True

        End Function

    Sunday, August 8, 2010 9:56 AM

Answers

  • 1) If your WCF is self hosted,  you do not need cross-domain policy file. Read this thread to see what is and what is not a cross-domain call and how to avoid cross-domain call for self hosted service:

    http://forums.silverlight.net/forums/p/24005/86247.aspx

    2) Make sure your DB connection is using SQL server authentication, not Windows authentication.

    Sunday, August 8, 2010 10:06 AM