我遇到麻烦并且在一个单独的日子里遇到了一个asp.net应用程序的头痛,它给我发了很多例外(使用global.asax)关于从dataReader引入的数据无法转换为特定类型。这里的奇怪问题是生成的代码,因为它在生产过程中从未改变过。
在任何情况下,dataReader都可以读取进程中另一个dataReader的信息吗?在应用程序中,dataReader的配置和连接在模块函数中完成,并在页面中调用该函数并使用该dataReader读取一些信息。 我没有发现这些问题。
如果您需要附加信息,请询问他们。
编辑:
我现在发布了一些代码来重新创建其中一个场景:
web project 1“application”:
Public Module funciones_asp
Public Function rs_dr(ByVal query As String) As SqlDataReader
Dim conexion As New SqlConnection("")
Dim comando As New System.Data.SqlClient.SqlCommand
comando.CommandTimeout = 0
comando.CommandType = System.Data.CommandType.Text
comando.CommandText = query
comando.Connection = conexion
conexion.Open()
rs_dr = comando.ExecuteReader(CommandBehavior.CloseConnection)
End Function
End Module
Public Class fw_empresa
Public Shared Sub rango_decimales(ByRef dec_unitario As Integer, ByRef dec_cantidad As Integer, ByRef dec_total As Integer)
Dim query As String = "SELECT decimal_field_1, decimal_field_2, decimal_field_3 FROM configuracion_decimales"
Using dr = rs_dr(query)
If dr.Read() Then
dec_unitario = dr.Item(0)
dec_cantidad = dr.Item(1)
dec_total = dr.Item(2)
End If
End Using
End sub
End class
web project 2“icomexvi”:
Public Class ic_proceso_embarque_UI
Inherits Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim DecimalesCantidad As Integer = 0
Dim DecimalesValor As Integer = 0
Dim DecimalesTotal As Integer = 0
application.fw_empresa.rango_decimales(dec_unitario, dec_cantidad, dec_total)
End Sub
End class
当天抛出我的例外是:
System.Exception: System.InvalidCastException: Conversion from string "1295|1|SIMPLE COLLECTION" to type 'Integer' is not valid. ---> System.FormatException: Input string was not in a correct format.
at Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble(String Value, NumberFormatInfo NumberFormat)
at Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(String Value)
--- End of inner exception stack trace ---
at Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(String Value)
at Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(Object Value)
at application.fw_empresa.rango_decimales(Int32& dec_unitario, Int32& dec_cantidad, Int32& dec_total) in D:\Publicaciones\Comex\Produccion\application\application\App_Clases\clases\fw_empresa.dal.vb:line 161
at icomexvi.ic_proceso_embarque_UI.Page_Load(Object sender, EventArgs e) in D:\Publicaciones\Comex\Produccion\application\icomexvi\proceso_embarque\principal.aspx.vb:line 4398
注意:
提前多多感谢!