connection string in asp.net?

hi

how can i make the connection string for a microsoft database in a web site

in windows applications i donnot need to mention the path so the application assume that the database is in the same path of the application

but what about in a web application

thanks for help


Answer this question

connection string in asp.net?

  • nerd_bomber

    server.mappath(".") determines the position based on based on it's current position in the file path. Sometimes it's better to use server.mappath("~") as that allows you to reference the root of the virtual web you're in. This article  has a good breakdown on using the tilde function.

    Cathal

  • wyzec

    hi

    sorry ,i mean microsoft access database

    away from storing the connection string in a configuration file,my question is how can i make the connection string so that when i upload the "web site" to a server
    i could access it ..........i wanna put the file of access database in the same folder of the dll file of the web site .....so what is the connection string should i use

    in windows application as i said in my first post there is no problem in just specifying the name of the database with no path if it is in the same directory of the .exe file

    so what about in web application

    thanks,

  • KPC

    Hi,

    What do you mean by a Microsoft Database Are you referring to MS Access
    You would store the ConnectionString in the web.config file and retrieve the same in code.

    Also note that, the forum for posting questions related to ASP.NET is:
    http://forums.asp.net/

    Regards,
    Vikram

  • Yahweh

    Hi,

    You can get the path from code. Use the following to get the physical path from within the ASP.NET Code:


    Server.MapPath(".")
     


    Once you do that, you will get the file system path upto the bin folder. If you place the DLL in the bin folder, then you would need to append "\bin\DB.mdb" to the path already retrieved.

    Regards,
    Vikram


  • zigy42

    hi

    thanks too mcuh for your help and fast response.

  • connection string in asp.net?