Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim reader As MySqlDataReader
Dim query As String
Dim md As String
md = Me.mskmembdate.Text
md = Me.bday.Text
md = Me.spsbday.Text
Try
If conn.State = ConnectionState.Closed Then
conn.Open()
End If
query = "SELECT * FROM member WHERE (memor = '" & membor.Text & "')"
sqlcom = New MySqlCommand(query, conn)
reader = sqlcom.ExecuteReader
While reader.Read()
Me.lblmembname.Text = reader("membname").ToString
Me.membtype.Text = reader("membtype").ToString
Me.mskmembdate.Text = CDate(reader("membdate")).ToString("MMddyyyy")
Me.lname.Text = reader("lname").ToString
Me.fname.Text = reader("fname").ToString
Me.mname.Text = reader("mname").ToString
Me.nameex.Text = reader("nameex").ToString
Me.bday.Text = CDate(reader("bday")).ToString("MMddyyyy")
Me.membtype.Text = reader("membtype").ToString
Me.spslname.Text = reader("spslname").ToString
Me.spsfname.Text = reader("spsfname").ToString
Me.spsmname.Text = reader("spsmname").ToString
Me.spsbday.Text = CDate(reader("spsbday")).ToString("MMddyyyy")
Me.civil.Text = reader("civil").ToString
Me.sex.Text = reader("sex").ToString
Me.municipal.Text = reader("municipal").ToString
Me.brgy.Text = reader("brgy").ToString
Me.purok.Text = reader("purok").ToString
Me.district.Text = reader("district").ToString
Me.certno.Text = reader("certnumb").ToString
Me.resno.Text = reader("resonumb").ToString
Me.cpno.Text = reader("cpno").ToString
Me.recstat.Text = reader("recstat").ToString
End While
reader.Close()
conn.Dispose()
Catch ex As Exception
End Try
Dim provider As String
Dim dataFile As String
Dim connString As String
Dim myConnection As OleDbConnection = New OleDbConnection
Dim dr As OleDbDataReader
provider = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source="
dataFile = "D:\N.A.C. JR\SAMPLE VB 2008\NewMembership\NewMembership\bin\Debug\profilepic.accdb"
connString = provider & dataFile
myConnection.ConnectionString = connString
myConnection.Open()
Dim str As String
str = "SELECT * FROM info WHERE (memor = '" & membor.Text & "')"
Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection)
dr = cmd.ExecuteReader()
While dr.Read()
orspspic.Text = dr("spspicture").ToString
orpic.Text = dr("picture").ToString
End While
dr.Close()
myConnection.Close()
varimage = orpic.Text
varimage = orspspic.Text
pic.ImageLocation = orpic.Text
spspic.ImageLocation = orspspic.Text
End Sub
这是来自frmload的代码我单击listview数据然后form2打开并将数据设置为文本框但是此错误弹出"已经有一个与此Connection关联的打开的DataReader必须先关闭" ?我该如何解决呢。任何想法如何解决这类问题?