DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C# (http://www.daniweb.com/forums/forum61.html)
-   -   How to remove uid and password in connection string? (http://www.daniweb.com/forums/thread192954.html)

pradeepfusion May 20th, 2009 9:52 am
How to remove uid and password in connection string?
 
Hi,
When I use sql server native client for odbc sql connection then it is asking uid and password, once I supply uid and pwd in odbc connection , I think there should not be necessary to give uid and password in C# in sql connection string. I want once we supply the dsn value to odbc sql connection string then it should not ask for uid and password which is already given in dsn creation. How can I resolve it ?

prasanna201 May 21st, 2009 8:59 am
Re: How to remove uid and password in connection string?
 
Quote:

Originally Posted by pradeepfusion (Post 872114)
Hi,
When I use sql server native client for odbc sql connection then it is asking uid and password, once I supply uid and pwd in odbc connection , I think there should not be necessary to give uid and password in C# in sql connection string. I want once we supply the dsn value to odbc sql connection string then it should not ask for uid and password which is already given in dsn creation. How can I resolve it ?

Hi,

Declare the connection string in web.config.

like below,
<configuration>
<appsettings>
<add key="Connectionstring" value="data source=ServerName;initial catalog=dbname;uid=username of sql server;pwd=password of the sql server">
</add>
</appsettings>
</configuration>

or declare the connection string in form level

public sqlconnection con=new sqlconnection (="data source=ServerName;initial catalog=dbname;uid=username of sql server;pwd=password of the sql server");

Thanks


All times are GMT -4. The time now is 6:01 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC