1,435 pts.
 Connection String for AS/400
Hi all. Here I'm using iSeries Server. I just want to connect VB.NET with AS/400 database. Simply I want to retrieve some data from a PF on VB.NET. Anybody can you tell me what is the connection string should be used? If you have any simple sample code in VB.NET please post here... Surey

Software/Hardware used:
V6R1, visual studio 2008
ASKED: February 14, 2013  8:29 AM
UPDATED: February 14, 2013  2:01 PM

Answer Wiki:
Last Wiki Answer Submitted:  Be the first to answer this question.
All Answer Wiki Contributors:  Be the first to answer this question. Michael Tidmarsh   11,380 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Before anyone can provide anything, we need to know what you are connecting with and what you are connecting to. What is the server OS version? What driver are you using? — Tom

 107,735 pts.

 
Hi Tom .. 
Server OS Version - V6R1M0 - i5/OS
and driver is ODBC .. 

You can suggest me which one is best driver. .
 1,435 pts.

 

…and driver is ODBC…
 
What ODBC driver? There is more than one possible to use. The first you should use is the IBM driver installed with iSeries Access. And iSeries Access should have the latest 6.1 service pack installed to ensure that you bypass any earlier issues that might have been found and fixed already.
 
Tom

 107,735 pts.

 

However, you might make better use of the IBM .NET data provider instead of the ODBC driver. — Tom

 107,735 pts.

 

Hi Tom… Our iSeries Access is 7.1 ..  If u can please explain me bit detailed. .because first time i’m trying this.. what is the connection string should be used. ? and how to fetch the data ?ThanksSurey.

 1,435 pts.

 

Please see Connection strings for AS/400 for different general formats. But we still don’t know which ODBC driver you’ll be using, nor do we know how you’re going to use it. You should develop a basic test function at the least. Then if you run into an obstacle, show the code. — Tom

 107,735 pts.

 
Hi Tom !this is my VB.NET code. Here I'm getting
ERROR[HYT00][IBM][System Access ODBC Driver]Connection login timed out error.


Imports System.Data.Odbc
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim cn As New OdbcConnection
        Dim cmd As New OdbcCommand
        Dim dbres As Integer

        Dim sql As String
        sql = "SELECT COUNT(*) FROM M1ATA00"

        Try
            cn.ConnectionString = "Driver={iSeries Access ODBC Driver};Data Source='Myiseries';System=XXXXXXXX;Uid='YYYYY';Pwd='ZZZZZ';"
            cn.Open()
            cmd.Connection = cn
            cmd.CommandType = CommandType.Text
            cmd.CommandText = sql

            dbres = Val(cmd.ExecuteScalar())
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try

        TextBox1.Text = dbres.ToString
        Exit Sub

        If dbres = 1 Then
            MessageBox.Show("Login Success")
        Else
            MessageBox.Show("Login Failed")
        End If

        cn.Close()
        cmd.Dispose()
        cn.Dispose()
    End Sub
End Class
 1,435 pts.

 

Anybody ?

 1,435 pts.

 

If the example is the code that you posted, what is “Data Source='Myiseries';“? I haven’t seen that before, though it looks like a variation of a DSN parameter and I wouldn’t expect a space to be valid. If you’re using a DSN, then some of the other parameters can’t be used. For “System=XXXXXXXX;“, are using a host name or an IP address? — Tom

 107,735 pts.

 

I added a comment, but it’s not showing up. It’s never clear why some comments seem to disappear. There’s nothing in that comment that seemed unusual. There’s a good chance it will be released in the morning and show up. — Tom

 107,735 pts.

 

In case my other comment doesn’t show up, try removing the “Data Source” parameter. Tell us if a different error appears. — Tom

 107,735 pts.