Click here to Skip to main content
14,775,221 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How do I publish a website of ASP.NET, C#, database and report rdlc in visual studio 2019 that can access by others using the link

What I have tried:

How do I publish a website of ASP.NET, C#, database and report rdlc in visual studio 2019 that can access by others using the link
Updated 2-Mar-20 23:32pm
Viswanatha Swamy 3-Mar-20 4:41am
Good afternoon. Could you please post the error message which you have posted earlier? Many thanks.
WeiJun420 3-Mar-20 4:49am
Actually i know how to publish the website,and can display well,but the database and report rdlc in my visual studio didnt display, i dont know how to connect to the database while publishing . Here is the error "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: SQL Network Interfaces, error: 50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details.
Viswanatha Swamy 3-Mar-20 4:57am
Good afternoon. Could you please paste the connection string inside the rdlc file. You can remove the User Name and Password before pasting the connection String
WeiJun420 3-Mar-20 5:01am
good afternoon,here is the connection string "Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\admin\source\repos\InventoryList\InventoryList\App_Data\InventoryList.mdf;Integrated Security=True" there is no username and password.
Viswanatha Swamy 3-Mar-20 5:04am
Thanks. I see you are connecting to your local database. Now the query is where are you publishing? If you are publishing to Azure OR Any other could, then the hosted application will be trying to reach the database with your local setting and will throw the above-mentioned exception. Could you please advise if you are hosting the website outside your Laptop?
WeiJun420 3-Mar-20 8:25am
I am publishing to IIS manager, do you have any idea what should i put the connection string?
Viswanatha Swamy 3-Mar-20 8:34am
Under the website, please navigate to ASP.Net, then double click "Connection Strings" and provide your connection string. Please let me know if that worked. Many thanks.
WeiJun420 3-Mar-20 20:14pm
Erm,i dont know where is it ...which website and how to navigate to

The error message is pretty specific:
The server was not found or was not accessible.

It even tells you what to check to find out why!

So check your connection string, make sure it is accessible from the server running your website, and that the supplied login ID / password combination is correct and valid for that server.
1. Open Internet Information Server.
2. Select your Website under Site.
3. In the right side panel you will see the section.
4. Double click the "Connection Strings" Icon and specify the connection string. The name of the connection string should exactly match with the existing name in your code.

You have to execute the below-mentioned commands from the command prompt.
C:\Users\PK.Viswanatha-Swamy>sqllocaldb info

C:\Users\PK.Viswanatha-Swamy>SQLLocalDB.exe start MSSQLLocalDB
LocalDB instance "MSSQLLocalDB" started.

sql server - MSSQLLOCALDB databases aren't listed - Stack Overflow[^]

Good afternoon. Could you please verify the Network Configuration (Enable Named Pipes and TCP/IP Connections) in SQL Server Configuration Manager. The error "Instance specific" points to that. Please refer to the link below for additional reference. Many thanks.

Aliases (SQL Server Configuration Manager) - SQL Server 2014 | Microsoft Docs[^]
WeiJun420 3-Mar-20 20:21pm
Inside my computer dont have SQL Server Configuration Manager, I use the SQL server that are already inside the visual studio 2019.
Viswanatha Swamy 3-Mar-20 23:45pm
Good morning. I have updated the solution 2 with the steps to add connection string inside your published website. Please let me know how did it go. Many thanks.
WeiJun420 3-Mar-20 23:59pm
It still prompt the same error, i already put the same connection string name but it still doesnt work.
Viswanatha Swamy 4-Mar-20 0:04am
Do you have SQL Server installed on your Laptop? Please advise.
WeiJun420 4-Mar-20 0:49am
Dont have. Do you know how to download?
Viswanatha Swamy 4-Mar-20 1:00am
Is there a way you can do the screen share. We both can hunt the issue. That will be faster.
WeiJun420 4-Mar-20 1:56am
if you are free now
sure can, by using teamviewer or?
Viswanatha Swamy 4-Mar-20 3:29am
Could you please paste the image of the Connection Strings section from IIS?
WeiJun420 4-Mar-20 3:36am
Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\InventoryList.mdf;Integrated Security=True
Viswanatha Swamy 4-Mar-20 3:41am
Please give me a few minutes. I am replicating the issue on my Laptop.
WeiJun420 4-Mar-20 3:42am
Viswanatha Swamy 4-Mar-20 4:18am
I have updated the solution 2. Please see the instructions and execute the commands. I have also given the URL for additional details. I have replicated the issue on my Laptop and execute the commands.
WeiJun420 4-Mar-20 4:43am
erm.. i already executed the command but still doesnt work...
Viswanatha Swamy 4-Mar-20 7:11am
Cool. Ok once you execute those commands it will create the database inside the C:\User folder. Inside your IIS could you please modify the connection string too Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\YourUserName\YourDatabaseName.mdf;Integrated Security=True;Connect Timeout=30
WeiJun420 4-Mar-20 20:29pm
good morning. I dont know what is going on, still cant...

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

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900