COMException durring data set loop

WellsCarrie

Well-known member
Joined
Jul 12, 2005
Messages
95
Location
Arkansas
Programming Experience
5-10
Ok I am getting an ADODB recordset back from the AS400 using the following
VB.NET:
[size=2][color=#0000ff]Private[/color][/size][size=2] strOmegaConn [/size][size=2][color=#0000ff]As[/color][/size][size=2][color=#0000ff]String[/color][/size][size=2] = "Provider=MSDASQL.1;User Id=filecopy;Data Source=Omega;Persist Security Info=false;Password=filecopy;"[/size]
[size=2][size=2][color=#0000ff]Private[/color][/size][size=2] gdcOmega [/size][size=2][color=#0000ff]As[/color][/size][size=2][color=#0000ff]New[/color][/size][size=2] ADODB.Connection[/size][/size]
[size=2][size=2][size=2][color=#008000]'RUN QUERY AND PROCESS THE RESULTS
[/color][/size][size=2]gdcOmega.ConnectionString = strOmegaConn[/size]
[size=2]gdcOmega.Open()[/size]
[size=2]rsResults = gdcOmega.Execute(strOmega)[/size]
[size=2][color=#0000ff]Do[/color][/size][size=2][color=#0000ff]While[/color][/size][size=2][color=#0000ff]Not[/color][/size][size=2] rsResults.EOF[/size]
[size=2]sb.Remove(0, sb.Length)[/size]
[size=2][color=#0000ff]For[/color][/size][size=2] i = 0 [/size][size=2][color=#0000ff]To[/color][/size][size=2] 17[/size]
[size=2][color=#0000ff]If[/color][/size][size=2][color=#0000ff]Not[/color][/size][size=2] IsDBNull(rsResults.Fields(i).Value) [/size][size=2][color=#0000ff]Then[/color][/size]
[size=2]sb.Append(Trim(rsResults.Fields(i).Value))[/size]
[size=2]sb.Append("~")[/size]
[size=2][color=#0000ff][size=2][color=#0000ff]Else[/color][/size][/color][/size]
[size=2][size=2][color=black]sb.Append(" ")[/color][/size][/size]
[size=2][size=2][color=black]sb.Append("~")[/color][/size][/size]
[size=2][color=#0000ff]End[/color][/size][size=2][color=#0000ff]If[/color][/size]
[size=2][color=#0000ff]Next[/color][/size]
[size=2]results(c) = sb.ToString()[/size]
[size=2]c += 1[/size]
[size=2][color=#0000ff]ReDim[/color][/size][size=2][color=#0000ff]Preserve[/color][/size][size=2] results(c)[/size]
[size=2]rsResults.MoveNext()[/size]
[size=2][color=#0000ff]Loop[/color][/size]
[size=2]rsResults.Close()[/size]
[size=2]gdcOmega.Close()[/size]
[/size][/size]

The query string is HUGE so I won't include it.

Everything works great until I get to {i = 8} of my for next. The value should be a date formated as yyyy-MM-dd what i get is "<error: an exception of type: {System.Runtime.InteropServices.COMException} occurred>".

I've read from the AS400 on numerious occasions and gotten lots of data fields in the last several weeks while we position ourselves to work with the new production applications being pushed to prod in December. Never have I gotten this.....

I am hoping some one can point me in the right direction. thanks.
 
Last edited by a moderator:
Back
Top