gpt4 book ai didi

.net - sqlconnection 未定义

转载 作者:行者123 更新时间:2023-12-02 17:38:19 27 4
gpt4 key购买 nike

我正在尝试更新一些代码。我有一个以此开头的 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 的类,并且 .NET 不知道要使用哪种类型,直到您指定 System.Data.SqlClient.SqlConnection > 明确的一个。

关于.net - sqlconnection 未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4684855/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com