Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim str As String = " SELECT date,h2 FROM History_sp"
Dim CountText As String = "SELECT COUNT(*) From History_sp" Dim conn1 As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\spdb.mdb;" & _
"User ID=Admin;" & _
"Password="
Dim conn As OleDbConnection = New OleDbConnection(conn1)
Dim mycommand As OleDbCommand = New OleDbCommand(str, conn)
Dim myCount As OleDbCommand = New OleDbCommand(CountText, conn)
conn.Open()
Dim ax()
Dim ay()
Dim i, NumPoints As Integer Dim myOleDbDataReader As OleDbDataReader = mycommand.ExecuteReader() NumPoints = myCount.ExecuteScalar()
ReDim ax(NumPoints - 1)
ReDim aY(NumPoints - 1) i = 0
While myOleDbDataReader.Read
ax(i) = myOleDbDataReader.GetValue(1)
ay(i) = myOleDbDataReader.GetValue(0)
i = i + 1
End While
myOleDbDataReader.Close()
conn.Close()
这是哪里的问题,谢谢
Dim str As String = " SELECT date,h2 FROM History_sp"
Dim CountText As String = "SELECT COUNT(*) From History_sp" Dim conn1 As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\spdb.mdb;" & _
"User ID=Admin;" & _
"Password="
Dim conn As OleDbConnection = New OleDbConnection(conn1)
Dim mycommand As OleDbCommand = New OleDbCommand(str, conn)
Dim myCount As OleDbCommand = New OleDbCommand(CountText, conn)
conn.Open()
Dim ax()
Dim ay()
Dim i, NumPoints As Integer Dim myOleDbDataReader As OleDbDataReader = mycommand.ExecuteReader() NumPoints = myCount.ExecuteScalar()
ReDim ax(NumPoints - 1)
ReDim aY(NumPoints - 1) i = 0
While myOleDbDataReader.Read
ax(i) = myOleDbDataReader.GetValue(1)
ay(i) = myOleDbDataReader.GetValue(0)
i = i + 1
End While
myOleDbDataReader.Close()
conn.Close()
这是哪里的问题,谢谢
请给myCount指定一个新的数据库连接