我正在尝试更新一些代码.我有一个以此开头的vb文件...
Imports System.Data.SqlClient
Imports System.Data.Sql
Imports System.Data.SqlTypes
Imports System.Configuration
<script runat="server">
Run Code Online (Sandbox Code Playgroud)
......而且它在这里失败了......
Using oConn As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("tps_write").ConnectionString())
Run Code Online (Sandbox Code Playgroud)
它返回的错误是......
"说明:在编译服务此请求所需的资源期间发生错误.请查看以下特定错误详细信息并相应地修改源代码.
编译器错误消息:BC30002:未定义类型"SqlConnection"."
我错过了一些系统类吗?
编辑:我更新了代码...
Using oConn As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("tps_write").ConnectionString())
Run Code Online (Sandbox Code Playgroud)
......它接受了它.为什么每次我使用该类中的对象时都需要显式写出System.Data.SqlClient?
所以,事实证明这条线是问题所在......
Using oConn As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("tps_write").ConnectionString())
Run Code Online (Sandbox Code Playgroud)
...我没有使用“tps_write”,而是将权限更改为“tpsWrite”。显然 tps_write 是一个过时的权限,不再在工作中使用。我希望错误消息更清晰。;)
感谢大家的帮助!