此代码将给出错误
Dim mysql As String = " Select roll_no,std_name from student"
Dim cmd As New OdbcCommand(mysql, conn)
conn.Open()
Dim reader As OdbcDataReader = cmd.ExecuteReader
conn.Close()
If reader.HasRows = True Then
End If
但这工作正常
Dim mysql As String = " Select roll_no,std_name from student"
Dim cmd As New OdbcCommand(mysql, conn)
conn.Open()
Dim reader As OdbcDataReader = cmd.ExecuteReader
If reader.HasRows = True Then
End If
conn.Close()
为什么阅读器始终需要打开连接才能从数据库中读取数据?