imports System imports System.data imports sql = System.Data.SqlClient public module MyModule Private intIndex as Integer = 0 Private dv as New DataView sub Main NorthwindDataSetDataView() NorthwindDataSetDataView() NorthwindDataSetDataView() AnyKey end sub Private Sub NorthwindDataSetDataView() Dim strSQL as String = "user id=sa;integrated security=SSPI;data source='(local)';Database=Northwind;" Dim cn AS new sql.SqlConnection cn.ConnectionString = strSQL Try ' Setup Command Dim cmd as new sql.SqlCommand cmd.CommandText = "SELECT * FROM [Customers]" cmd.CommandType = CommandType.Text cmd.Connection = cn Dim da as new sql.SqlDataAdapter da.SelectCommand = cmd Dim ds as New DataSet da.Fill(ds, "MyTableName") dv = New DataView(ds.Tables(0)) intIndex += 1 Dim strField As String = dv.Item(intIndex).Item(2).ToString WL("Element(" & intIndex & ",1)",strField) cmd = Nothing da = Nothing cn.Close() cn = Nothing Catch ex As Exception WL("Error", ex.Message.tostring) End Try End Sub sub WL(strItem as string, objValue as Object) ' paramarray Dim strValue As String = CType(objValue, String) Console.WriteLine(strItem & ": [" & strValue & "]") end sub sub WL(strItem as string) Console.WriteLine(strItem) end sub sub AnyKey WL("") Console.Write("Press enter key to continue... ") RL() end Sub end module