Solved

ASP.Net C# ODBC username password

Posted on 2012-04-10
4
1,279 Views
Last Modified: 2012-04-10
Hey folks.  I have been working with a connection to a IBM AS400 DB2 database ODBC conneciton on a local host in an ASP.NET C# web project... and it working fine due to the ODBC connection using my windows authenication.

When I pusblish my project to the sever, when the DataSet is called it errors with...

ERROR [28000] [IBM][System i Access ODBC Driver]Communication link failure. comm rc=8015 - CWBSY1006 - User ID is invalid, Password length = 0, Prompt Mode = Never, System IP Address = MyIPAddress

I am assuming it has no username and or password... how do I give it one?  Is this set up through the ODBC Connection or is it passed in the code or is there a better way.

I HAVE to use an ODBC connection due to the mainframe database.

I am a newb when it comes to ASP.NET and C# so please help with a code example.


<add name="ConnectionString" connectionString="DSN=AS400TestPLTX;"
      providerName="System.Data.Odbc" />

above is the code... can I enter UID = MyUserID and PWD=$@#$... if so what is the syntax.

Thanks All!!!!

Wayne
0
Comment
Question by:COFIT
  • 2
  • 2
4 Comments
 
LVL 2

Expert Comment

by:Kelden
ID: 37828547
You can try:
<add name="ConnectionString" connectionString="DSN=AS400TestPLTX;User Id=myUsername;Password=myPassword;"
      providerName="System.Data.Odbc" />

or

<add name="ConnectionString" connectionString="DSN=AS400TestPLTX;Uid=myUsername;Pwd=myPassword;"
      providerName="System.Data.Odbc" />


For a good list of connection strings check
http://connectionstrings.com/
0
 

Author Comment

by:COFIT
ID: 37830018
I miss spoken earlier , my apologies.

This Connection is made in this Class .... how can I pass username and password here?



        public static DataSet GetData(string sql)
        {

            System.Data.Odbc.OdbcConnection con = new System.Data.Odbc.OdbcConnection("Dsn=AS400TestPLTX");
            System.Data.Odbc.OdbcDataAdapter da = new System.Data.Odbc.OdbcDataAdapter(sql, con);
            System.Data.DataSet ds = new System.Data.DataSet();
            da.Fill(ds);

            return ds;
        }
0
 
LVL 2

Accepted Solution

by:
Kelden earned 500 total points
ID: 37830193
System.Data.Odbc.OdbcConnection con = new System.Data.Odbc.OdbcConnection("Dsn=AS400TestPLTX;User Id=myUsername;Password=myPassword;");

or

System.Data.Odbc.OdbcConnection con = new System.Data.Odbc.OdbcConnection("Dsn=AS400TestPLTX;Uid=myUsername;Pwd=myPassword;");
0
 

Author Comment

by:COFIT
ID: 37830330
System.Data.Odbc.OdbcConnection con = new System.Data.Odbc.OdbcConnection("Dsn=AS400TestPLTX;Uid=myUsername;Pwd=myPassword;");

This one works ... thx for the help!!!  

I tried all sorts of irritations of this yesterday... just could not get the syntax correct.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question