1

This is my simple Code which stores parameters value in variables and use it on query but it's give me ERROR message "INVALID Object name "DTA010.DFDR00" because I guess i'm not connected with the AS/400

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //string strQuery;

        string order_no = Request.QueryString["order"];
        if (order_no != null)
        {
            Response.Write("\n");
            Response.Write("Order No is ");
            Response.Write(order_no);
        }
        else
        {
            Response.Write("You Order number is not correct");
        }

        Response.Write("Your Order Status is");
        Response.Write(niceMethod1());
        Response.Write("\n");

    }

    public string niceMethod1()
    {
        string tDate = "";

        string nOrder = (Request.QueryString["order"] ?? "0").ToString();

        using (SqlConnection connection = new SqlConnection("Data Source=*****;User ID=web;Password=****;Initial Catalog=WEBSTATUS;Integrated Security=False;"))
        {

            string commandtext = "SELECT A.STAT01 FROM DTA010.DFDR00 AS A WHERE A.ORDE01 = @nOrder"; //@nOrder Is a parameter

            SqlCommand command = new SqlCommand(commandtext, connection);

            //command.Parameters.AddWithValue("@nPhone", nPhone); //Adds the ID we got before to the SQL command
            command.Parameters.AddWithValue("@nOrder", nOrder);
            connection.Open();
            tDate = (string)command.ExecuteScalar();
        } //Connection will automaticly get Closed becuase of "using";
        return tDate;
    }
}

The drivers needed to connect from a .NET application to a AS/400 are properly installed.

  • 2
    possible duplicate of [Connect to AS400 using .NET](http://stackoverflow.com/questions/3336646/connect-to-as400-using-net) – Jason Nov 09 '12 at 17:17
  • Read the linked question - it is exactly the issue you're dealing with. You need to install IBM drivers in order to connect to an AS/400 from .NET – Jason Nov 09 '12 at 17:20
  • I just didn't find any thing from where I can connect. – user1812816 Nov 09 '12 at 18:40

3 Answers3

3

If the names of the schema (aka library) and table (aka file) are spelled correctly, try replacing the period with a slash /. This would be used for "system" naming syntax, rather than "standard" naming syntax.

WarrenT
  • 4,502
  • 19
  • 27
0

You are definitely connected. I think the issue may be in the error you received. Make sure that the object exists that you are connecting to. WRKOBJ OBJ(BTGDTA010/DF01HDR00) will see if it exists. Check that everything is spelled right. It might be a typo.

Mike Wills
  • 20,959
  • 28
  • 93
  • 149
0

Here is the simplest way I Found may be useful for someone..!!

First need to add Assembly IBM library and

using IBM.Data.DB2.iSeries;

then

 iDB2Connection connDB2 = new iDB2Connection(
            "DataSource=158.7.1.78;" +
            "userid=*****;password=*****;DefaultCollection=MYTEST;");