Imports System.Data.SqlClient Imports System.Data.Sql Imports System.Data.SqlTypes Imports System.Configuration <script runat="server">
……而且它在这里失败了……
Using oConn As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("tps_write").ConnectionString())
它返回的错误是……
“Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30002: Type ‘SqlConnection’ is not defined.”
我错过了一些系统类吗?
编辑:我更新了代码…
Using oConn As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("tps_write").ConnectionString())
……它接受了它.为什么每次我使用该类中的对象时都需要显式写出System.Data.SqlClient?
解决方法
EDIT: I updated the code to this…
Using oConn As
System.Data.SqlClient.SqlConnection =
New
System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings(“tps_write”).ConnectionString())…and it accepts it. Why do I need to
explicitly write out
System.Data.SqlClient every time I use
an object from that class???
我最好的猜测是,有一个名为SqlConnection的类,在您明确指定System.Data.SqlClient.SqlConnection之前,.NET不知道要使用哪种类型.