hello all,
as i know that if we don't want to specify the static path of databse
then ,
we can use "Server.mapPath" like,( in any .aspx page )
str = "Data Source=.\\SQLEXPRESS;AttachDbFilename=" + Server.MapPath("student1.mdf") + ";" + "Integrated Security=True;User Instance=True";
but my question is that ,
why this "Server.mapPath" can't work with in the any .class file
in c# ( and also vb.net )
like,
/// <summary>
/// Summary description for sql_data
/// </summary>
///
public class sql_data
{
public SqlConnection conection = new SqlConnection();
public SqlCommand sql1 = new SqlCommand();
public string str;
public sql_data()
{
str = "Data Source=.\\SQLEXPRESS;AttachDbFilename=" + Server.MapPath("student1.mdf") + ";" + "Integrated Security=True;User Instance=True";
this.conection = new SqlConnection(str);
}
}
because i want to make a class wich contain sql conection,sql command & adapter etc which can define in the class & can be used
in my entire web site
pls help me to solve this problem
i have search so many web site but i can't get proper web site
thanx in advance