Hey, Sorry if my Englise bad![]()
I need to use the MapPath function in myClass file, For a Database declaration.
Private objConnAsNew OleDbConnection("Provider=" & _"Microsoft.Jet.OLEDB.4.0;" & _"Data Source=C:\websites\myWebSite\Website.mdb")This Conn String Work, but when i upload my website to the Server i need to use MapPath.
So, How i Use the MapPath funciton in myClass File?
Thanks!
Hi,
you cannot use Server.MapPath in layers different to presentation , and it seems to use it the data access logic ?
So you could use a similar approach:
string baseDir = AppDomain.CurrentDomain.BaseDirectory; // this will return the directory of your web site
string dataSource = baseDir + "Website.mbd";
Private objConnAsNew OleDbConnection("Provider=" & _"Microsoft.Jet.OLEDB.4.0;" & _dataSource)
Cheers,
Yani
0 comments:
Post a Comment