Sqlconnection not defined

I am trying to update some code. I have a vb file that starts with this ...

Imports System.Data.SqlClient
Imports System.Data.Sql
Imports System.Data.SqlTypes
Imports System.Configuration

<script runat="server">

... and he does not work here ...

Using oConn As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("tps_write").ConnectionString())

Return Error ...

"Description: An error occurred while compiling the resource needed to service this request. Review the following specific error information and modify the source code accordingly.

Compiler Error Message: BC30002: Type "SqlConnection" not defined. "

Am I missing some kind of system class?

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 he accepts it. Why do I need to explicitly write out System.Data.SqlClient every time I use an object from this class ???

+5
source share
4 answers

, , ...

Using oConn As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("tps_write").ConnectionString())

... "tps_write", "tpsWrite". -, tps_write - , . , .;)

!

+1

EDIT: ...

oConn As System.Data.SqlClient.SqlConnection = System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings( "tps_write" ). ConnectionString())

... . System.Data.SqlClient , ???

: SqlConnection, .NET , , System.Data.SqlClient.SqlConnection.

+1

-, System.Data. " ". .NET System.Data.dll "".

0

, web.config. ,

<connectionStrings>
<--! Below is your connection string>
<add name="ConnName" connectionString="Data Source=PROGRAMMER2\SQLServer;Initial Catalog=PPSSecurity;Integrated Security=true;" />
</connectionStrings>
0

All Articles