I have a webform with a class that has the ConnectionString to connect to my SQL database. My issue is trying to access the class in the code behind.
Here is my class:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
/// <summary>
/// Summary description for DBConnection
/// </summary>
///
public static class DBConnectdb
{
public static string con;
public static void ConnectSQL()
{
string ConnectionString = ConfigurationManager.ConnectionStrings["VisitorTrackingConnectionString"].ConnectionString;
SqlConnection con = new SqlConnection(ConnectionString);
con.Open();
}
public static string GetCon()
{
return con;
}
}
My code behind where I am trying to call the class:
Go to the complete details ...