Solved

ASP.Net C# ODBC username password

Posted on 2012-04-10
4
1,316 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

717 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