Connecting to SQL Server 2008 from code

Discussion in 'Databases' started by Spanky, Dec 11, 2009.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Having trouble getting a connection to the SQL Serve database in code. Can connect using the SQL management tool and the connection params provided by discountasp.net, but can't do so in code on our site yet.

    Does anyone have some sample code that shows the correct way to do this?

    Or do you have a sample of how to output an exception coming from SQLException which is being caught in a catch statement?
     
  2. Bruce

    Bruce DiscountASP.NET Staff

  3. There is no SQL 2008 sample code that works. I also cannot get my site to talk to the 2008 Server. I checked that page I dont see anything for 2008. On DiscountASP, SQL 2000 uses an ODBC to connect which works. 2009 does not have the same option. Any ideas? The Connection string provided in the 2008 database view console doesn't work.
     
  4. Add to Knowledgebase

    You might want to add this to the Knowledge Base:

    Dreamweaver Connection string:

    "Provider=SQLOLEDB;Data Source=YOURDBSERVER;Initial Catalog=YOURDBNAME;User Id=YOURUSERID;Password=YOURPASSWORD;Connect Timeout=15;Network Library=dbmssocn;"

    This works fine, it was not clear as this is not what is listed on the DB console at my.discountasp.net

    Mike
     
  5. mjp

    mjp

    Thanks!
     
  6. helpforhorm

    helpforhorm Guest

    in the control panel they dont give you a provider to use

    you can copy the connection string form the control panel, but it is not complete, you have to specify a provider to use.

    So just add "Provider=SQLOLEDB; " to the start of what they give you. (without the quotes obviously)
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page