Saeed
Saeed

Reputation: 7370

Where to put "using" in a vb file of an asp project?

I am developing an asp website, and in a .vb file I want to connect to database, so I have to use System.Data.SqlClient

P.S: But I don't know where to put the using statement. I used to work with c# in asp, and there we put the using statement at the top of the file. But here it says statements should not be outside a method body or multiline lambda.

Upvotes: 1

Views: 56

Answers (1)

Jon Egerton
Jon Egerton

Reputation: 41549

The equivalent of the C# using statement in this context is imports. It goes at the top of the file same as using in C#

e.g. Imports System.Web

There is also a using statement, used to declare disposaible objects

e.g.

using (CN as new SQLConnection)
{
...
}

Upvotes: 1

Related Questions