executereader error
Posted by: jude Ulanday
Date: July 18, 2019 01:02AM

hi, I have a vb program that wants to retrieve data from MySQL dbase.

this code is working fine :

Dim vDATE As String

vDATE = mDATE.ToString("yyyy/MM/dd", System.Globalization.CultureInfo.InvariantCulture)
Dim connstring As String = "server=xxx.xxx.x.xx;database=dbname;uid=idko;Pwd=passko"
Using con As New MySqlConnection(connstring)
con.Open()
Dim query As String = "SELECT issue_date, inc_date, exp_date, total FROM table_name WHERE COC_DATE = @DATE "
Dim MYSQLCMD As New MySqlCommand(query, con)
MYSQLCMD.Parameters.AddWithValue("@DATE", vDATE)
Dim reader As MySqlDataReader = MYSQLCMD.ExecuteReader
While reader.Read
MessageBox.Show(reader.GetString(0) & vbCr & reader.GetString(1) & vbCr & reader.GetString(2) & vbCr & reader.GetString(3))
End While
End Using

but the code below give me an error that says "A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond"

Dim vDATE As String

vDATE = mDATE.ToString("yyyy/MM/dd", System.Globalization.CultureInfo.InvariantCulture)
Dim connstring As String = "server=xxx.xxx.x.xx;database=dbname;uid=idko;Pwd=passko"
Using con As New MySqlConnection(connstring)
con.Open()
Dim query As String = "SELECT ref_no,name, address,zipcode FROM table_name WHERE COC_DATE = @DATE "
Dim MYSQLCMD As New MySqlCommand(query, con)
MYSQLCMD.Parameters.AddWithValue("@DATE", vDATE)
Dim reader As MySqlDataReader = MYSQLCMD.ExecuteReader
While reader.Read
MessageBox.Show(reader.GetString(0) & vbCr & reader.GetString(1) & vbCr & reader.GetString(2) & vbCr & reader.GetString(3))
End While
End Using

any help would be greatly appreciated.

thank you.

Options: ReplyQuote


Subject
Written By
Posted
executereader error
July 18, 2019 01:02AM
July 19, 2019 04:07AM
July 18, 2019 08:52AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.