• GoDaddy Community
  • Websites + Marketing | Website Builders
  • Websites + Marketing | Website Builders

    cancel
    Showing results for 
    Show  only  | Search instead for 
    Did you mean: 
    Go to solution

    GridView.DataBind() results in A network-related or instance-specific error occurred while establish

    Hi Guys
    I'm trying to deploy my asp.net web form app on Godaddy .I can connect to the Sql Server and everything goes well,i.e authentication goes well but as soon as the line "gridview1.DataBind()" is being executed I receive this error message:

    "[SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)]"

    I can connect from my own machine to the server database,i do not receive that error while running from my own machine and I'm sure my app is connected to database still receiving that error.
    My .net framework is 4.5.2 and server's is
    4.7.02558.Do you think this is because of the framework?
    By the way here is a snippet of code around the line causing the error:

    string selectSQL = "SELECT * FROM Users AS u INNER JOIN Roles AS r ON r.ID = u.FK_Users_Role";

            SqlConnection con = new SqlConnection(connectionString);
            DataTable ds = new DataTable();
            SqlCommand cmd = new SqlCommand(selectSQL, con);
            ///
            
            SqlDataAdapter adapter = new SqlDataAdapter(cmd);
            //DataTable ds = new DataTable();
            adapter.Fill(ds);

            if (ds.Rows.Count > 0) //Check if DataTable returns data
            {
                grvUsers.DataSource = ds;
                grvUsers.DataBind();-------->error
            }

            else //else if no data returned from the DataTable then
            {    //call the method ShowNoResultFound()
                ShowNoResultFound(ds, grvUsers);
            }

    Thank you in advance.

    5 REPLIES 5
    Helper V
    Helper V

    Re: GridView.DataBind() results in A network-related or instance-specific error occurred while estab

    @Mary1982,

     

    Are you able to connect to SQL Server and display the records in local development environment without any errors?, or you're getting the same error...

     

    Regards,

     

    Praveen Thomas

    GoDaddy 24/7 Support www.x.co/247support
    ----->NEXIA

    Re: GridView.DataBind() results in A network-related or instance-specific error occurred while estab

    Hi Parveen

    Yes, I can even connect to server's database both with my app,with no error,

    also with ssms.It's really weird that i receive this error right at this point: gridview.databind()

    Helper V
    Helper V
    Solution

    Re: GridView.DataBind() results in A network-related or instance-specific error occurred while estab

    @Mary1982,

     

    The issue might be because of the deprecated .NET framework, anyway check this...

    https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/index

    Please check the above example for connecting to SQL server and manipulate data...

     

    Thank you

     

    Regards,

     

    Praveen Thomas

    GoDaddy 24/7 Support www.x.co/247support
    ----->NEXIA

    Re: GridView.DataBind() results in A network-related or instance-specific error occurred while estab

    Thanks for the response

    I'm trying to install .net framework 4.7 but its not working for me.

    I tried updating my windows,tried several solutions but none of those worked for me.

    Helper V
    Helper V

    Re: GridView.DataBind() results in A network-related or instance-specific error occurred while estab

    @Mary1982,

     

    Installing .NET Framework 4.7 on hosting server?, or local environment...

    What is your local environment setup?...

    Are you using Visual Studio development server?, or something else...

     

    Looking forward to hear from you...

     

    Regards,

     

    Praveen Thomas

    GoDaddy 24/7 Support www.x.co/247support
    ----->NEXIA