?
Solved

ASP.Net C# ODBC username password

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

801 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