Solved

ASP.Net C# ODBC username password

Posted on 2012-04-10
4
1,224 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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:…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

706 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now