vb.net - 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 以作为值返回。
解决方案
这是我的错。从未检查连接字符串是否正确进入函数。一旦我纠正了这一点(给出正确的连接字符串),一切都按我的预期进行。总之谢谢大家。
推荐阅读
- python - Tensorflow:从图像中预测一个点,用点标签训练模型
- javascript - 点击时更改图像网址时猫头鹰轮播不更新
- reactjs - 样式化的组件道具 React js
- c# - How can I fix a warning saying something is missing in instantiate?
- c# - 更新在 Entity Framework Core 中将值设置为 null
- python - 在单独的表单值发生更改时更新 django 模型表单值
- javascript - a href 部分不适用于 safari 和 firefox
- java - 在 Java 中,什么是比 stream().forEach() 更有效但仍使用流操作的方法?
- google-cloud-platform - 无法从所有角色中包含服务帐户的计算引擎访问 bigquery
- swift - 复制和粘贴时如何阻止Textview也复制格式?