P
Patrick Olurotimi Ige
Why do i get "Invalid attempt to FieldCount when reader is closed"
Is the problem the way the datareader reads data as
opposed to a dataset?
When trying to compile this code:-
Dim reader As IDataReader = GetReader()
Dim chart As New LineChart()
chart.DataXValueField = "Product"
chart.DataYValueField = "Price"
chart.DataSource = reader
chart.DataBind()
reader.Close()
ChartControl1.Charts.Add(chart)
Dim chart1 As New LineChart()
chart1.DataSource = reader
chart1.DataXValueField = "Product2"
chart1.DataYValueField = "Price2"
Getting the error here---> chart1.DataBind()
ChartControl1.Charts.Add(chart1)
reader.Close()
ChartControl1.RedrawChart()
With the function:-
Function GetReader() As IDataReader
Dim connection As new OleDbConnection("")
Dim command As new OleDbCommand("SELECT Top 10 [ProductName] As
Product,[UnitPrice] As Price, [UnitsInStock] As Stock FROM Products
order by UnitPrice desc", connection)
connection.Open()
Return command.ExecuteReader(CommandBehavior.CloseConnection)
End Function
Is the problem the way the datareader reads data as
opposed to a dataset?
When trying to compile this code:-
Dim reader As IDataReader = GetReader()
Dim chart As New LineChart()
chart.DataXValueField = "Product"
chart.DataYValueField = "Price"
chart.DataSource = reader
chart.DataBind()
reader.Close()
ChartControl1.Charts.Add(chart)
Dim chart1 As New LineChart()
chart1.DataSource = reader
chart1.DataXValueField = "Product2"
chart1.DataYValueField = "Price2"
Getting the error here---> chart1.DataBind()
ChartControl1.Charts.Add(chart1)
reader.Close()
ChartControl1.RedrawChart()
With the function:-
Function GetReader() As IDataReader
Dim connection As new OleDbConnection("")
Dim command As new OleDbCommand("SELECT Top 10 [ProductName] As
Product,[UnitPrice] As Price, [UnitsInStock] As Stock FROM Products
order by UnitPrice desc", connection)
connection.Open()
Return command.ExecuteReader(CommandBehavior.CloseConnection)
End Function