ResultSetクラスGetDataAsString()、IsDataNull()は引数としてカラム番号を必要とします。
カラム数が多い場合等に、カラム名で指定を行う別の方法があります。
以下に、System.Collections.SortedListを使用して実現する例を示します。
Dim rs As CacheObject.ResultSet
rs = factory.DynamicSQL("SELECT * from DateTest")
rs.Execute()
''' +++ カラム情報を取得し保存 +++
Dim i As Integer
Dim dt As Date
Dim columns As Integer
Dim counter As Integer
Dim sortedList As New System.Collections.SortedList
columns = rs.GetColumnCount()
For counter = 1 To columns
sortedList.Add(rs.GetColumnName(counter), counter)
Next
''' --- カラム情報を取得し保存 ---
''' +++ 使用例 +++
While rs.Next()
System.Console.WriteLine(rs.GetDataAsString(sortedList.GetByIndex(sortedList.IndexOfKey("aCurrency"))))
System.Console.WriteLine(rs.GetDataAsString(sortedList.GetByIndex(sortedList.IndexOfKey("aDate"))))
System.Console.WriteLine(rs.GetDataAsString(sortedList.GetByIndex(sortedList.IndexOfKey("aInteger"))))
System.Console.WriteLine(rs.GetDataAsString(sortedList.GetByIndex(sortedList.IndexOfKey("aString"))))
If rs.IsDataNull(sortedList.GetByIndex(sortedList.IndexOfKey("aCurrency"))) = True Then
System.Console.WriteLine("aCurrency is Null")
End If
If rs.IsDataNull(sortedList.GetByIndex(sortedList.IndexOfKey("aDate"))) = True Then
System.Console.WriteLine("aDate is Null")
End If
If rs.IsDataNull(sortedList.GetByIndex(sortedList.IndexOfKey("aInteger"))) = True Then
System.Console.WriteLine("aInteger is Null")
End If
If rs.IsDataNull(sortedList.GetByIndex(sortedList.IndexOfKey("aString"))) = True Then
System.Console.WriteLine("aString is Null")
End If
End While
rs.Close()
''' --- 使用例 ---