Bob wrote:
Hello folks,
I am tring to create a connection to a SQL Server 2005 database but
cannot. I get an error messahe that
SQL Server does not exist or access denied
I have tried Windows Authentication and I have tried SQL Server
Authentication.
I have tried numerous connection strings...so I don't think it is the
connection string.
I must be missing something obvious....or something
dumb....interesting it is that I can connect using ado and Microsoft
Access.
Anybody got any ideas?
Regards,
Bob Sweeney
Try something like this. Seems to work fine for me, dont forget to check the
ports in firewalled connections to allow 1433.....
public static void NewSQLConnection()
{
//Gets the location of the SQL database server.
string datasource = ApplicationSettings.MeetySettings.DNS + "\\"
+ ApplicationSettings.MeetySettings.Instance;
//Builds a connection string to connect to the database.
string connectionString = "user id=" +
ApplicationSettings.MeetySettings.Username +
"; pwd=" + ApplicationSettings.MeetySettings.Password +
"; Initial Catalog=" +
ApplicationSettings.MeetySettings.TableName +
"; Data Source=" + datasource +
";Packet Size=4096" +
";Connection Timeout=15;";
//Creates a new instanse of SqlConnection using the connection
settings above.
ApplicationSettings.MeetySettings.SQLConnection = new
SqlConnection(connectionString);
//Keep a record of the amount of data the connection is
transfering
ApplicationSettings.MeetySettings.SQLConnection.St atisticsEnabled
= true;
}
--
Regards JJ (UWA)