INTELLIGENT WORK FORUMS FOR COMPUTER PROFESSIONALS
Come Join Us!
- Talk With Other Members
- Be Notified Of Responses
To Your Posts
- Keyword Search
- Turn Off Ad Banners
- One-Click Access To Your
Favorite Forums
- Automated Signatures
On Your Posts
- Best Of All, It's Free!
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.
Partner With Us!
"Best Of Breed" Forums Add Stickiness To Your Site

(Download This Button Today!)
Member Feedback
"...Keep up the good work - excellent site - i'd been looking for something like this for ages !..."
Geography
Where in the world do Tek-Tips members come from?
|
Visual Basic(Microsoft) -VB.NET 2002-2008 FAQ
|
How-to
|
Create a connection to an AS400
Posted: 28 Feb 06
|
Create a connection to an AS400 and fill a list view with results
Copy all the steps into an event and try it ....
Step 1
CODE'Define the ODBC Connection string Dim MyODBCConnection As New OdbcConnection("Driver={Client Access ODBC Driver (32-bit)};" & _ "System=AS400Name;" & _ "TRANSLATE=1;" & _ "Uid=UserID;" & _ "Pwd=User Password") 'Open the connection MyODBCConnection.Open()
Step 2
CODE'Define the SQL statement to extract the data from the AS400 Dim selectCMD As OdbcCommand = New OdbcCommand("SELECT * FROM LIBRARY.FILE WHERE FILEFIELD='YourChoice' order by FILEFIELD", MyODBCConnection)
Step 3
CODE'Initialize the reader Dim dr As OdbcDataReader = selectCMD.ExecuteReader
Step 4
CODETry 'Set the mouse to show a Wait cursor Me.Cursor = Cursors.WaitCursor 'start the Read loop While dr.Read 'Note: the numbers in double quotes represent the column number from the AS400 database 'Add the data to the list view Dim listItem As New ListViewItem(dr.GetString("2")) listItem.SubItems.Add(dr.GetString("3")) ListView1.Items.Add(listItem) 'End the loop End While 'Reset the cursor Me.Cursor = Cursors.Default
Catch ex As Exception End Try
Step 5
CODE'Close the connection MyODBCConnection.Close() MyODBCConnection.Dispose()
And that's all there is to it. Of course, this is probably the simplest scenario, but you get the idea - you can build on this!
![[2thumbsup] 2thumbsup](http://www.tipmaster.com/images/2thumbsup.gif) |
Back to Visual Basic(Microsoft) -VB.NET 2002-2008 FAQ Index
Back to Visual Basic(Microsoft) -VB.NET 2002-2008 Forum
My FAQ Archive
Email This FAQ To A Friend |
|
 |
|