View Full Version : Connecting to SQL Server 2008 from code
Spanky
12-11-2009, 04:03 PM
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?
bruce
12-17-2009, 08:43 PM
see http://support.discountasp.net/KB/c87/sample-code.aspx
Fever
12-23-2009, 01:03 AM
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.
Fever
12-23-2009, 01:13 AM
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
helpforhorm
01-07-2010, 05:21 PM
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)
vBulletin® ©Jelsoft Enterprises Ltd.