Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Connecting string to SQL Server
Message
 
 
À
03/01/2012 10:59:49
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
C# 2.0
Divers
Thread ID:
01532080
Message ID:
01532105
Vues:
23
>>>>>>Hi,
>>>>>>
>>>>>>When I am testing my ASP.NET to connect to SQL Server I use the following connecting string:
>>>>>>
>>>>>>
>>>>>>connString = "server=MYCOMPUTER\\SQLEXPRESS; database=MyDatabaseName; Trusted_Connection=Yes"
>>>>>>
>>>>>>
>>>>>>But I get an error:
>>>>>>
>>>>>>
>>>>>>Cannot open database "MyDatabaseName" requested by login. The login failed. 
>>>>>>Login failed for user 'MYCOMPUTER\Dmitry' 
>>>>>>
>>>>>>
>>>>>>I suppose the "Trusted_Connection" syntax is not recognized, right? What should I change in my connString?
>>>>>
>>>>>You could try swapping it for 'Integrated Security=True' - but the simplest way to get it right might be to just let the IDE create the string via ServerExplorer ?
>>>>
>>>>I don't know, yet, how to use ServerExplorer. I am just trying to create a "Hello World" of the SQL Server connection (if you know what I mean). Changing Trusted_Connection to Integrated Security didn't solve the problem. I suppose next I need to create a log in (learn how) in the SQL Server and enter the 'uid' and 'pwd' in the connection string.
>>>
>>>In VS:
>>>Select View/ServerExplorer from the menu.
>>>Right click 'DataConnections' in the Server Explorer Window and choose 'Add Connection'.
>>>Choose Server Name, Authentication etc in the pop-up window.
>>>Use 'Test Connection' to verify that it works.
>>>With the connection added to the ServerExplorer window right click on it and choose 'Properties'. The string you need is shown in the properties window....
>>>
>>>HTH
>>
>>This is very helpful. I learned that my test database is the problem. I keps getting the error 'Login failed for user 'MYCOMPUTER\Dmitry' when using my test database. So I suppose my the user Dmitry does not have access rights to this database. When I changed the database name to another, the error was gone. I will have to learn how to assign my test database (or any database) to be accessable with Integrated Security. If you have any suggestions, please let me know.
>>
>>Thank you very much for your help!
>
>Bear in mind that if this is an ASP.NET app then in production the user identity will be that configured on the IIS application pool and might vary depending on the configuration or even the IIS version. It may be better to access the DB under a specific user account and store that in encrypted form in the web.config......

My plan is to enter in the web.config, as a key, pointer to an XML file (e.g. MyAppSqlConfig.xml) where the SQL Server database configuration will reside (e.g. Server name, database name, user name, password, etc.). At run-time this XML file will be opened, parsed and a connecting string will be created. I have not thought about encryption yet. I suppose I will have to figure that part, somehow.

Thanks.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform