微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

.net – 没有定义sqlconnection

我正在尝试更新一些代码.我有一个以此开头的vb文件

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不知道要使用哪种类型.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐