Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: MySQL VB.NET
When I try retrive a data from a MySQL database using the ExecuteReader() command i receive a timeout error like this :
 
TimeoutException was unhandled : 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.
 
Can any one state a possible reason for this exception.
 
The troublesome fragment of code is as under :
 
 
Dim connectionst As String = connectionstring   'String concealed 
 Dim querystring As String = "SELECT dat1 FROM mydb WHERE dat2 = '" + txtbox.Text + "';"
Dim commandgive As New MySqlCommand(querystring)
         Dim commandgive As New MySqlCommand(querystring)
        commandgive.Connection = connection
        connection.Open()
        Dim dataread As MySqlDataReader
        dataread = commandgive.ExecuteReader() 'Problematic code.
        MsgBox(dataread.GetInt32(0))
 
        dataread.Close()
        connection.Close()
connection.Close()
 
The line commented a problematic code is where vb shows me a timeout exception.
 
Why is this so ?
Posted 18-Apr-13 16:10pm
Edited 18-Apr-13 16:13pm
v2
Comments
Bernhard Hiller at 19-Apr-13 2:52am
   
Where does the MySQL sever run - on the same machine as your code, or on a different machine?
compuknow at 19-Apr-13 3:59am
   
The application runs on the same machine where the MySQL server runs. In my connection string , i have mentioned localhost.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Well, either your connection string is wrong (great job keeping an important piece of information hidden!) and you're not really connecting to the box you think you are or your MySQL server didn't respond with the query results in the default time allowed to execute the command (usually 30 seconds).
 

That's about all anyone can tell you given the lack of information provided.
  Permalink  
Comments
compuknow at 18-Apr-13 22:10pm
   
sir , what information is lacking ? I could have provided.
 
It would not be right to reveal a connection string in a Public domain as it contains security information.
 

 
The connection string is right , because it worked when i was inserting data into this same database , the connection string used for insertion is being used here for extraction.
 
The query string must be right because , i know there exists those columns which are being reffered in that query string.
 
Could you suggest any other method for receiving data other than ExecuteReader() ?
Dave Kreskowiak at 19-Apr-13 8:22am
   
It has nothing to do with the syntax of your query. I already told you what the two possibilites are for this error. Have a nice day.
compuknow at 19-Apr-13 10:55am
   
The query string executes when executed through the MySQL Command Line Client.
 
ExecuteReader() must return perfectly because the query hits well through the dedicated command line client of MySQL.
 

The connection string works well with ExecuteNonQuery() Command , but not with ExecuteReader() command.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 575
1 Kornfeld Eliyahu Peter 409
2 Maciej Los 369
3 DamithSL 196
4 OriginalGriff 188
0 OriginalGriff 6,353
1 DamithSL 4,854
2 Maciej Los 4,466
3 Kornfeld Eliyahu Peter 4,058
4 Sergey Alexandrovich Kryukov 3,897


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 18 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100