Connect to DB2 of V5R1 from .NET application

2245 pts.
Tags:
.NET applications
AS/400
IBM DB2
Hi all, I want to connect to AS/400 DB2 from my .NET application. I just want to know which are prerequisites for this connectivity and data retrieval.

Answer Wiki

Thanks. We'll let you know when a new response is added.

You may want to use something like this.

I use it for running SQL over multiplie i-series/DB@ connections
strConnection = “DataSource=10.10.10.11;userid=MYID;password=MYPWD;DefaultCollection=MYDATALIB;Pooling=False;Connect Timeout=30;”

Dim myConnection As New iDB2Connection(strConnection)
Dim myCommand As New iDB2Command(mySQL, myConnection)

myCommand.CommandTimeout = 0
myCommand.Connection.Open()

Dim myReader As iDB2DataReader
Try
 myReader =myCommand.ExecuteReader(CommandBehavior.CloseConnection)

            If myReader.HasRows = False Then
                lblError.Text = “No rows returned for SQL statement”
                lblError.Visible = True

                myReader.Close()
                myConnection.Close()
                dgResults.DataSource = Nothing
                dgResults.DataBind()

            Else

                Dim fields As Integer = myReader.FieldCount

                dgResults.DataSource = myReader
                dgResults.DataBind()

                myReader.Close()
                myConnection.Close()

                lblError.Text = ” “
                lblError.Visible = False

            End If

        Catch ex As Exception
            lblError.Text = ex.Message
            lblError.Visible = True

        End Try

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • hunshabbir7
    Thanks ToddN2000 for always helping. I was hoping that you will reply because you are working on both .net and as400. Actually I have gone through this code many times, I want to know which dlls are required, you must be using some provider from which you are using iDB2DataReader, iDB2Connection and iDB2Command etc. 
    2,245 pointsBadges:
    report
  • ToddN2000
    Right click your project when it's open in solution explorer.
    click on add reference.
    click the .net tab.
    then click on IBM DB2 for i.NET Provider



    14,920 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following