Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ASP.Net C# ODBC username password

Posted on 2012-04-10
4
Medium Priority
?
1,365 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 2000 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
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…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

610 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