Posted on: 5/13/2011 10:57:28 AM | Views : 311

hey all,
I am trying create a function in a class file from the App_Code folder.  What i am trying to accomplish is a function to connect to the database so i dont have to use db connection 2 times for each code behind page but instead just access the function.  what i have for the class code is:
namespace TestApp { public class AccessData { public static void OpenConnection() { string connectionString = GetConnectionString(); using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); } } static public string GetConnectionString() { return "Data Source=(.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\Record_Review.mdf);" + "Integrated Security=True;User Instance=True"; } } }  here is where ...

Go to the complete details ...