c# - Authorization to DB2 database using ADO.NET in Visual Studio 2010 -


im using code connect db2 database - testing purposes :

private void ctss_connect(object sender, routedeventargs e) {     idb2connection nc = new idb2connection();     nc.connectionstring = "datasource=as400machine; defaultcollection=mydatabase;";     nc.open();     nc.close(); } 

the problem program ask me once userid , password. when debug program next time, login machines without prompt userid , password. should add connectionstring or there hidden in visualstudio settings?

i'm using ibm iaccess windows , personal communicator access as400 machine when run program popup windows personal communicator have enter userid , password

my guess credentials cached somehow. .net-db2-ado.net-library.

this setting in personal communicator might help:

pc settings


i use following connectionstring db2 databases, contains both username , password program not have ask user:

datasource=xxx;userid=xxx;password=xxx;checkconnectiononopen=true;datacompression=true; 

replace "xxx" follows:

afaik, datasource can hostname or ipv4-adress.
userid: db2-user
password: password


i recommend storing connectionstrings in app.config file like:

<?xml version="1.0"?> <configuration>   <connectionstrings>     <add name="as400_s"          connectionstring="datasource=127.0.0.1;userid=somedb2user;password=somedb2password;checkconnectiononopen=true;datacompression=true;" />   </connectionstrings> </configuration> 

you can access via c# code:

var appconfig = configurationmanager.openexeconfiguration("your.exe"); string connectionstring = appconfig.connectionstrings.connectionstrings["connstring1"].connectionstring; 

or:

string connectionstring = configurationmanager.connectionstrings["connstring1"].connectionstring; 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -