0

I have used mysql for my web application in asp.net . However while running it in browser it shows me this error.

System.TimeoutException: Unable to read data from the transport connection: 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. ---> 
System.IO.IOException: Unable to read data from the transport connection: 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. --->
System.Net.Sockets.SocketException: 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 at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) at 
System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) --- End of inner exception stack trace --- at
System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) at MySql.Data.Common.MyNetworkStream.Read(Byte[] buffer, Int32 offset, Int32 count) --- End of inner exception stack trace --- at 
MySql.Data.Common.MyNetworkStream.Read(Byte[] buffer, Int32 offset, Int32 count) at 
MySql.Data.MySqlClient.TimedStream.Read(Byte[] buffer, Int32 offset, Int32 count) at 
System.IO.BufferedStream.Read(Byte[] array, Int32 offset, Int32 count) at MySql.Data.MySqlClient.MySqlStream.ReadFully(Stream stream, Byte[] buffer, Int32 offset, Int32 count) at 
MySql.Data.MySqlClient.MySqlStream.LoadPacket() at MySql.Data.MySqlClient.MySqlStream.ReadPacket() at MySql.Data.MySqlClient.NativeDriver.Open() at MySql.Data.MySqlClient.Driver.Open() at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings) at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection() at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection() at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver() at MySql.Data.MySqlClient.MySqlPool.GetConnection() at MySql.Data.MySqlClient.MySqlConnection.Open() at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at 
System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable) at 
school.Page_Load(Object sender, EventArgs e) in 
E:\VIDYAN\school.aspx.vb:line 20

Connection String

<add name="constr" connectionString="Data Source=localhost;port=81;Initial Catalog=Vidyan;User Id=root;password="/>

VB code

Imports System.Data
Imports System.Configuration
Imports MySql.Data.MySqlClient
Partial Class school
    Inherits System.Web.UI.Page

    Dim constr As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
    Dim query, str As String

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
            ViewState("Data") = ""
            Using con As New MySqlConnection(constr)
                Using cmd As New MySqlCommand("SELECT * FROM school")
                    Using sda As New MySqlDataAdapter()
                        cmd.Connection = con
                        sda.SelectCommand = cmd
                        Using dt As New DataTable()
                            sda.Fill(dt)
                            ViewState("Data") = dt
                            schoollists.DataSource = dt
                            schoollists.DataBind()

                        End Using
                    End Using
                End Using
            End Using

        Catch ex As Exception
            Response.Write(ex)
        End Try
    End Sub

    Protected Sub DataPager1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
        Try
            Dim table As DataTable = ViewState("Data")
            schoollists.DataSource = table
            schoollists.DataBind()

        Catch ex As Exception
            'Response.Write(ex)
        End Try

    End Sub
End Class
8
  • @wingᴇdpᴀnᴛʜᴇʀ tried this and got error again. updated in my question.. Commented Oct 17, 2015 at 9:51
  • 1
    First question, is this localhost or remote? Second question, have you checked firewalls? A timeout on a connection is typical behavior of a firewall Commented Oct 17, 2015 at 9:57
  • @Neo it is localhost connection. mysql running under wamp server. And fiewall is off.. Commented Oct 17, 2015 at 10:02
  • 1
    Can you add your connection string onto the question, also if you are using WAMP can PhpMyAdmin access it? Is the service for MySQL running? Commented Oct 17, 2015 at 10:05
  • 1
    Thanks for adding, the first thing that stands out is port 81, mysql is 3306 have you changed the listening port? Commented Oct 17, 2015 at 10:09

1 Answer 1

1

The default port for MySQL is 3306, in your connection string it is 81, I'd check the port for WAMP and try 3306 :)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.