Connecting to SQL Server with Asp.net

Within Web.config

Then Create a Class under "App_Code" and create a class within that folder named "util".

Imports Microsoft.VisualBasic

Public Class util
    Shared Function ConString() As String
        ConString = ConfigurationManager.AppSettings("SqlConnection").ToString()
    End Function
End Class


And whenever you need to access connection string, simply do..

util.ConString

You do not need to creat ea reference to util class, since its in app_code folder, and no instance name of util class required, since the Function is "Shared"


 

 

Posted by:

No comments posted.

Name :  

Email :  

Comment Below