我知道已针对此特定错误消息提出了多个问题,但没有一个与我所经历的有关。
我有一个 Silverlight 和 WCF 项目。我正在调用 wcf 服务并很好地检索数据。我的服务中有多种功能,它们都工作得很好。
我的问题是,我调用了刚刚创建的函数,并收到“远程服务器返回错误:未找到”错误消息。不知道为什么。我已经构建了 wcf 项目并在 silverlight 中更新了服务。错误列表不显示任何内容。
任何帮助将不胜感激!!!!
我有一个类级别的变量,它是我的 Web 服务。
Silverlight 中的代码:
Private WithEvents Service As WebService.SQLServiceClient = GetNewService()
Private Sub btnSave_Click(sender As Object, e As System.Windows.RoutedEventArgs) Handles btnSave.Click
Dim View As PagedCollectionView = dgDeficiences.ItemsSource
Service.SaveChangesAsync(txtLOB.Text, View.SourceCollection)
End Sub
WCF 中的代码:
<OperationContract()>
Public Function SaveChanges(ByVal LOB As String, ByVal Deficiences As List(Of Deficiences)) As Boolean
Dim DT_Old, DT_New, DT_Changes As DataTable
Dim Conn As New SqlConnection(ConnectionString)
Dim Cmd As New SqlCommand(String.Empty, Conn)
DT_Old = GetSQLData(CommandType.StoredProcedure, "EHL_GetLookups", {"Section", "Data"}, {3, LOB})
If DT_Old.Rows.Count < 1 Then Return False
'Copy deficiencies in sql to DT_New
DT_New = DT_Old.Copy
'Update 3 fields with data user provided
For i As Integer = 0 To Deficiences.Count - 1
'Find deficiency row to update by ID field
For j As Integer = 0 To DT_New.Rows.Count - 1
If DT_New.Rows(j)("DeficiencyID") = Deficiences(i).DeficiencyID Then
DT_New.Rows(j)("Status") = Deficiences(i).Status
DT_New.Rows(j)("PatternOfCare") = Deficiences(i).PatternOfCare
DT_New.Rows(j)("MarketNarrative") = Deficiences(i).MarketNarrative
Continue For 'Next Deficiency
End If
Next
Next
'Set primary key so merge works correctly
DT_Old.PrimaryKey = {DT_Old.Columns("DeficiencyID")}
DT_New.PrimaryKey = {DT_New.Columns("DeficiencyID")}
'Make sure all row status = unchanges
DT_Old.AcceptChanges()
'Merge user's changes to data in database
DT_Old.Merge(DT_New)
'Get rows with changes
DT_Changes = DT_Old.GetChanges()
'Save changes to SQL
For i As Integer = 0 To DT_Changes.Rows.Count - 1
Cmd.CommandText = "UPDATE dbo.EHL_Deficiency_NewEHLTest " _
& "SET Status='" & DT_Changes.Rows(i)("Status") & "', Pattern_Of_Care='" & DT_Changes.Rows(i)("PatternOfCare") & "', Market_Narrative='" & DT_Changes.Rows(i)("PatternOfCare") & "' " _
& "WHERE DeficiencyID=" & DT_Changes.Rows(i)("DeficiencyID")
Cmd.ExecuteNonQuery()
Next
If DT_Changes.Rows.Count < 1 Then Return False Else Return True
End Function