Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to connet to SQL Server newbie?
Message
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Divers
Thread ID:
00940862
Message ID:
00940988
Vues:
15
Although the syntax that you used should work if you are logged in as an administrator on your machine (and the database name is correct (database name is not case-sensitive)), you might try the more common syntax of:
cn.ConnectionString = "server=(local);database=Northwind;Integrated Security=SSPI;";
More commonly, however, systems are written using SQL Server authentication rather than Windows Authentication (provided, of course, that you set SQL Server up in mixed mode so that you can use either type of authentication).

In that case, the syntax is:
cn.ConnectionString = "Data Source=localhost;" +
           "Initial Catalog=Northwind;user id=userid;password=password";
First, note that the above user id is a SQL Server user id, not a Windows user id (Set that up in Enterprise Manager in the Security folder.)

Secondly, note that there are several equivalent ways of designating a connection string. "localhost" is equivalent to "(local)" (in most installations, that is), "Initial Catalog" is equivalent to "database". The syntax in the second example, however, is the most common and, I believe, the preferred syntax for connecting to SQL Server. (I hope I'm not starting a holy war here!)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform