使用webservice更新数据出错,请大家指教

chen6191 2005-03-29 10:28:26
webservice中的更新代码:
<WebMethod()> Public Function UpdateData(ByVal change As DataSet) As DataSet
If Not (change Is Nothing) Then
Dim mycmd As SqlCommand = New SqlCommand("select * from enjoy", Me.SqlConnection1)
myadapter = New SqlDataAdapter(mycmd)
myadapter.Update(change)
Return change
Else
Return Nothing
End If
End Function

应用程序中的代码:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If myset.HasChanges() Then
Dim ws As New localhost.Service1
ws.Credentials = System.Net.CredentialCache.DefaultCredentials
ws.UpdateData(myset)
MsgBox("更新完成")
End If
End Sub

当我在datagrid(数据源是myset)中修改了数据,点击button2按纽欲更新数据时出错,提示信息如下:

未处理的“System.Web.Services.Protocols.SoapException”类型的异常出现在 system.web.services.dll 中。
其他信息: 服务器无法处理请求。 --> 当传递具有已修改行的 DataRow 集合时,更新要求有效的 UpdateCommand。
...全文
154 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
ziyan0218 2005-03-29
  • 打赏
  • 举报
回复
up
MyLf 2005-03-29
  • 打赏
  • 举报
回复
这不是Webservice的问题。是基本的Ado.Net更新数据的问题。
在myadapter.Update(change)前,你要产生一个SqlCommandBuilder:
SqlCommandBuilder cb = new SqlCommandBuilder(myadapter)

12,162

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧