locked
System.ComponentModel.Win32Exception: The network path was not found RRS feed

  • Question

  • Server Error in '/' Application.

    The network path was not found

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.ComponentModel.Win32Exception: The network path was not found

    Source Error:
    Line 18:     {
    Line 19:         SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["connect"].ToString());
    Line 20:         con.Open();
    Line 21:         String query = "select (*) from login where email=" +txt_email.Text+ " and pass_=" +txt_pass.Text+ " ";
    Line 22:         SqlCommand cmd = new SqlCommand(query, con);

    Source File: e:\Work\NMIT\Graduate Diploma Project\BookMyFirm\Admin\Default.aspx.cs    Line: 20

    Stack Trace:
    [Win32Exception (0x80004005): The network path was not found]
    
    Monday, September 14, 2020 10:20 AM

All replies

  • I would say the the conntionstring is not correct. You should  review it. You should debug the program to ensure that the program is getting the connectionstring.

    Monday, September 14, 2020 11:22 AM
  • I wrote this connection string:
    <connectionStrings>
    <add name="connect" connectionString="Data Source=localhost_52844;Initial Catalog=E:\Work\NMIT\Graduate Diploma Project\BookMyFirm\App_Data\login.mdf;Integrated Security=True" providerName="System.Data.SqlClient"/>
    </connectionStrings>
    Monday, September 14, 2020 11:45 PM
  • Hi thewarriorprince,
    >>Initial Catalog=E:\Work\NMIT\Graduate Diploma Project\BookMyFirm\App_Data\login.mdf;
    The InitialCatalog property is used to get or set the name of the database associated with the connection.
    And AttachDBFilename property is used to get or set a string that contains the name of the primary data file. And this includes the full path name of an attachable database.
    So you can change the "Initial Catalog" to "AttachDBFileName".
    Best Regards,
    Daniel Zhang


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, September 15, 2020 2:45 AM
  • Hello Daniel, Thank you for your response! I did but though I am getting same error! 

    Deafault.cs :

    protected void Btn_login_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["connect"].ToString());
            con.Open();
            String query = "select (*) from login where email=" +txt_email.Text+ " and pass_=" +txt_pass.Text+ " ";
            SqlCommand cmd = new SqlCommand(query, con);
            string output = cmd.ExecuteScalar().ToString();

            if(output=="1")
            {
                Response.Redirect("~/Admin.html");
            }

            else
            {
                Response.Write("You have entered the wrong credentials!");
            }

    System.Data.SqlClient.SqlException: '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)'

    Tuesday, September 15, 2020 11:52 AM
  • The error line is   con.Open();
    Tuesday, September 15, 2020 11:53 AM
  • I wrote this connection string:
    <connectionStrings>
    <add name="connect" connectionString="Data Source=localhost_52844;Initial Catalog=E:\Work\NMIT\Graduate Diploma Project\BookMyFirm\App_Data\login.mdf;Integrated Security=True" providerName="System.Data.SqlClient"/>
    </connectionStrings>

    the catalog is not correct 

    https://www.dofactory.com/connection-strings

    Tuesday, September 15, 2020 4:36 PM
  • The error line is   con.Open();
    It is based on the connectionstring being correct. 
    Tuesday, September 15, 2020 4:37 PM
  • Hi Vishvat Gautami,
    Are you connected to the local sql server?
    If so, you can refer to these threads to check your conntionstring.
    [How to get the connection String from a database]
    [Sql connection-string for localhost server]
    Best Regards,
    Daniel Zhang


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Wednesday, September 16, 2020 2:31 AM