Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Anyone using AS/400 with .NET?

Status
Not open for further replies.

bigfoot

Programmer
May 4, 1999
1,779
US
I just started using .NET. All my apps from VB^ will connect just fine, but when I try to make a connection in .NET, it fails. Why?

Anyone doing this? I want to be able to read an AS/400 file and put it into a Dataset, change it, and write it back. This should be so simple.
 
I put the connection sting in my web.config file like this...

<appSettings>
<add key=&quot;AS400&quot; value=&quot;Provider=IBMDA400.DataSource.1;Password=password;Persist Security Info=True;User ID=UserName;Data Source=dsName;Protection Level=None;Transport Product=Client Access;SSL=DEFAULT;Force Translate=65535;Default Collection=UserName;Convert Date Time To Char=TRUE;Catalog Library List=defaultLibrary&quot;/>
</appSettings>

then call the data set like this

Private Sub AccountList()
Dim strSQL As String
strSQL = &quot;sql statement&quot;

Dim dr As OleDbDataReader
dr = GetDataReader(strSQL)

cmbAccounts.Items.Clear()
While dr.Read()
Dim Acct As New ListItem()
Acct.Text = Left(dr.GetString(0), 3) & &quot;-&quot; & Mid(dr.GetString(0), 4, 3) & &quot;-&quot; & Mid(dr.GetString(0), 7, 1)
Acct.Value = dr.GetString(0)
cmbAccounts.Items.Add(Acct)
cmbAccounts.SelectedIndex = 0
End While
dr.Close()
End Sub


GetDataReader looks like

Private Function GetDataReader(ByVal sqlText As String) As OleDbDataReader

Dim dr As OleDbDataReader
Dim cnn400ole As OleDbConnection = New OleDbConnection(ConfigurationSettings.AppSettings(&quot;AS4001&quot;))
Dim oleCmd As OleDbCommand = New OleDbCommand(sqlText, cnn400ole)
oleCmd.Connection.Open()
dr = oleCmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
Return dr

End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top