Connecting to your online SQL Database with Visual Web Developer

Last post 11-10-2006 7:23 PM by shados. 3 replies.

Sort Posts:

  • Connecting to your online SQL Database with Visual Web Developer

    11-10-2006, 5:54 PM
    • Participant
      870 point Participant
    • ianmoore
    • Member since 09-14-2006, 5:00 PM
    • Posts 174

    Hi Everyone,

    I have recently learnt how to get my SQL database uploaded onto my internet server host with a great tutorial in FAQ

    I am FTPing my Visual Web Developer Website up onto my internet host server and I want the website to be connected to the database so that I can use GridView and DataView etc.

    I would now like to make my CONNECTION srting in my web.config file

    by default the connection Visual Web Developer makes is:

    ------------------------------------------------------------------------------------------------------------------

    <

    add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True"

    providerName="System.Data.SqlClient" />

     ------------------------------------------------------------------------------------------------------------------

     How do I determine the exact DataDirectory that my host server stores the SQL database at? I think there is an automatic way of determining this?

    Also: now that I have uploaded my database from Visual Web Developer do I have to change any other part of the connection string?

    can someone give me an example of a functioning string for this.

    thanks for your help. Geeked

    Happiness is a skill
  • Re: Connecting to your online SQL Database with Visual Web Developer

    11-10-2006, 6:17 PM
    • Star
      12,126 point Star
    • shados
    • Member since 07-07-2006, 7:24 PM
    • Posts 2,202

    Since your database is not an independant MDF now, but is permanently part of the server, you have to take a different approach at the connection string. Nothing else in your code will have to change though. Here is a sample example:

    <

    add name="ConnectionString" connectionString="Data Source=123.123.123.123,1234;Initial Catalog=mydbname;Persist Security Info=True;User ID=francois;Password=ward1234" providerName="System.Data.SqlClient"/>

     And no, these are not the user name and passwords I normaly use :) You will recognise above that you need to use the same info you used to connect remotly to your database when you used SQL Management Studio Express

  • Re: Connecting to your online SQL Database with Visual Web Developer

    11-10-2006, 6:32 PM
    • Participant
      870 point Participant
    • ianmoore
    • Member since 09-14-2006, 5:00 PM
    • Posts 174

    Perfect!

    thank you.

    in my case I have written my host name rather than the IP address... so I have written     mydomainname.com   instead of 123.123.123.123.1234

    I now have a fully functional database and connection.CoolYes

     
    Happiness is a skill
  • Re: Connecting to your online SQL Database with Visual Web Developer

    11-10-2006, 7:23 PM
    • Star
      12,126 point Star
    • shados
    • Member since 07-07-2006, 7:24 PM
    • Posts 2,202

    Congrats :)

     

Page 1 of 1 (4 items)