首页 > 解决方案 > System.Web.Services.Protocols.SoapException

问题描述

此错误以 5:1 的比率生成。4 次它会正常工作,但下一次运行它会为相同的查询字符串返回错误“对象引用未设置为对象的实例”。

我的系统使用 Web 服务 (SVC) 连接到 MySql 数据库以进行所有 CRUD 操作。错误如下所示:

System.Web.Services.Protocols.SoapException: DELETE FROM customer_number WHERE cus_id =4 对象引用未设置为对象的实例。在 System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) 在 System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) 在 POS.ThePOSServerService Reference.vb:line 266 中的 .PosMain.ExecuteQueryBool(String strQuery, String Company, String User, String Pass)

虽然生成错误的代码如下所示: Try 261 Dim ConnectionString As String = _ ConfigurationManager.ConnectionStrings(Company).ConnectionString 262 'Dim sCommand As StringBuilder = New 262 - StringBuilder(strQuery) 263 Using mConnection As MySqlConnection = New MySqlConnection(ConnectionString) 264 mConnection.Open() 265 Using myCmd As MySqlCommand = New MySqlCommand(strQuery, mConnection) 266 myCmd.CommandType = CommandType.Text 267 Result = myCmd.ExecuteNonQuery() > 0 268 End Using 269 End Using Catch ex As Exception Throw New ApplicationException(ex.ToString) End Try 我只想让 Result 为 True 或 False 以作为值返回。

标签: vb.net

解决方案


这是我的错。从未检查连接字符串是否正确进入函数。一旦我纠正了这一点(给出正确的连接字符串),一切都按我的预期进行。总之谢谢大家。


推荐阅读