Reputation: 2066
So I need to add a "using" statement which is :
using System.Data.SqlClient
in my webpage so i dont have to call whats inside the SqlClient with the whole statement
System.Data.SqlClient.SqlConnection con = new ..
How to do that ?
note that i added the reference System.Data to my webconfig file.
Upvotes: 23
Views: 19850
Reputation: 23220
At the top of your Razor View just add
@using System.Data.SqlClient
Notice the @
char before the using statement.
Or inside a block like below:
@{
using System.Data.SqlClient;
}
Side note: it's a little bit weird to use a SqlConnection
into a Razor View.
Upvotes: 40