Realise this has been asked before but i have been unable to find a solution that works in this case.
I am trying to connect to a sql database over a network. The server is 2008 and the application is VB.Net (4).
The offending script is;
Dim strConnection As String = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=XXXX;Password=XXXX;Initial Catalog=MBB;Data Source=NETPC\SQLEXPRESS"
con = New OleDbConnection(strConnection)
con.Open()
The user id and password connect and has write permission to the db
using SQL Management Studio.
I have tested the connection string using the .udl quick test where
it worked fine and matched the string above.
The db is set up to accept both windows & sql server (password
protected) authentication.
Actual error is;
An unhandled exception of type 'System.Data.OleDb.OleDbException'
occurred in System.Data.dll Additional information:
[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or
access denied.
I usually connect to MySQL via odbc but in this special instance I need to connect via sqlconnection and binding it to a dropdown. Here's my script
Using con As New SqlConnection("Data Source=101.99.69.30; Database=recon; User ID=recon; PASSWORD=recon123;")
Using cmd As New SqlCommand("SELECT fid, fmake, fmodel FROM treconcalculation")
cmd.CommandType = CommandType.Text
cmd.Connection = con
Using sda As New SqlDataAdapter(cmd)
Dim ds As New DataSet()
sda.Fill(ds)
vehicle1.DataSource = ds.Tables(0)
vehicle1.DataTextField = "fmodel"
vehicle1.DataValueField = "fid"
vehicle1.DataBind()
End Using
End Using
End Using
vehicle1.Items.Insert(0, New ListItem("--Select Customer--", "0"))
The problem is, it gives me this error at line 19.
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)
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.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)
Source Error:
Line 17: Using sda As New SqlDataAdapter(cmd)
Line 18: Dim ds As New DataSet()
Line 19: sda.Fill(ds)
Line 20: vehicle1.DataSource = ds.Tables(0)
Line 21: vehicle1.DataTextField = "fmodel"
I've confirmed with the odbc string I usually use and the source, database, user id and password is correct. what seems to be the problem? Thanks
This might be due to any of the below issues.
1) Network issue
2) SQL Server configuration issue
3) Firewall issue
4) Client driver issue
5) Application configuration issue
6) Authentication and logon issue
Some ways to check this:
1. Check if your SQL has started:
Start->Control Panel -> Administration Tools -> Services.
Find the firewall service here to see if it is disabled.
If not, right click the service and select Stop from the context menu.
2. Make sure your database engine is configured to accept remote connections:
a) Open SQL Server Management Studio.
b) Right click SQL Server instance -> Properties -> Connections -> Check the Allow remote connections to this server box.
c) Go to the General section and check name of SQL Server specified in the Name field.
I m using Pentaho v5.2. When i tried to connect to sql server i m end with below error. I had downloaded and placed required driver sqljdbc4-2.0 jar in pdi-ce-5.2.0.0-209\data-integration\lib. Please help me as I'm new to Pentaho.
Error connecting to database [mssqlserverconn] : org.pentaho.di.core.exception.KettleDatabaseException:
Error occured while trying to connect to the database
Error connecting to database: (using class com.microsoft.sqlserver.jdbc.SQLServerDriver)
Login failed for user 'Lenovo-PC\RamaKrishna'.
org.pentaho.di.core.exception.KettleDatabaseException:
Error occured while trying to connect to the database
Error connecting to database: (using class com.microsoft.sqlserver.jdbc.SQLServerDriver)
Login failed for user 'Lenovo-PC\RamaKrishna'.
From the error message you're being thrown, it's an authentication issue.
It looks like you are trying to use your username from your laptop domain - is that what you want? Does the the server accept this user name (Lenovo-PC\RamaKrishna)?
You may have been using integrated security, which basically overrides whatever you set as the username in the text-box and uses your Windows username instead.
See below:
I am trying to create an ApplicationEndpoint by first creating and establishing the CollaborationPlatform using ProvisionedApplicationPlatformSettings, when i execute:
ProvisionedApplicationPlatformSettings settings = new ProvisionedApplicationPlatformSettings("MYAPP", _appID);
_collabPlatform = new CollaborationPlatform(settings);
_collabPlatform.BeginStartup(EndPlatformStartup, _collabPlatform);
in EndPlatformStartup method while executing collabPlatform.EndStartup(ar); i get an error
ProvisioningFailureException:
One or more values in the configured settings are invalid or unusable. Check inner exception and logs for more details.
The settings wrapper failed to initialize.
Unable to find the Sqld database: 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: 26 - Error Locating Server/Instance Specified)
Found the Answer/Error,
i was trying to run the application from Windows 7 PC which apparently is not supported for Auto Provisioned Application , so now i build the application on my Win7 PC and then execute it on the Lync Server.
I'm running my code and getting this error. But what does it mean?
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:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Stack Trace:
[Win32Exception (0x80004005): The network path was not found]
[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)]
This is probably related to your database connection string or something like that.
I just solved this exception right now. What was happening is that I was using a connection string intended to be used when debugging in a different machine (the server).
I commented the wrong connection string in Web.config and uncommented the right one. Now I'm back in business... this is something I forget to look at after sometime not working in a given solution. ;)
You will also get this exact error if attempting to access your remote/prod db from localhost and you've forgotten that this particular hosting company requires VPN logon in order to access the db (do i feel silly).
There may be some reasons like:
Wrong SQL connection string.
SQL Server in services is not running.
Distributed Transaction Coordinator service is not running.
First try to connect from SQL Server Management Studio to your Remote database. If it connects it means problem is at the code side or at Visual Studio side if you are using the one.
Check the connectionstring, if the problem persists, check these two services:
Distributed Transaction Coordinator service
SQL Server services.
Go in services.msc and search and start these two services.
The above answer works for the Exception:
[Win32Exception (0x80004005): The network path was not found]
Possibly also check the sessionState tag in Web.config
Believe it or not, some projects I've worked on will set a connection string here as well.
Setting this config to:
<sessionState mode="InProc" />
Fixed this issue in my case after checking all other connection strings were correct.
Same problem with me. I solved this by adding # before connection string (C# has a thing called 'String Literals') like so:
SqlConnection sconnection = new SqlConnection(#"Data Source=(Localdb)\v11.0; Initial Catalog=Mydatabase;Integrated Security=True");
sconnection.Open();
As others pointed out this could be more to do with the connectionstring config
Make sure,
user id and password are correct
Data Source is pointing to correct one , for example if you are using SQL express it will be .\SQLEXPRESS
Database is pointing to correct name of database
Hope that helps.
check your Connection String Properly.
Check that the connection is open.
String CS=ConfigurationManager.COnnectionStrings["DBCS"].connectionString;
if(!IsPostBack)
{enter code here
SqlConnection con = new SqlConnection(CS);
con.Open();
SqlCommand cmd = new SqlCommand("select * from tblCountry", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
//Bind data
}
I recently had the same issue. It's more likely that your application can not connect to database server due to the network issues.
In my case I was connected to wrong WiFi.
At The Beginning, I faced the same error but with a different scenario.
I was having two connection strings, one for ado.net, and the other was for the EntityFramework, Both connections where correct. The problem specifically was within the edmx file of the EF, where I changed the ProviderManifestToken="2012" to ProviderManifestToken="2008" therefore, the application worked fine after that.
In my case, I had generated DbContext from an existing database. I had my connection string set in appSettings.json file; however, when I generated the class files by scaffolding the DbContext class it had incorrect connection string.
So make sure your connection string is proper in appSettings.json file as well as in DbContext file. This will solve your issue.
On my end, the problem was an unsuccessful connection to the VPN (while working from home). And yeah, the connectionString was using a context from remote server. Which resulted in the following error:
<Error>
<Message>An error has occurred.</Message>
<ExceptionMessage>The network path was not found</ExceptionMessage>
<ExceptionType>System.ComponentModel.Win32Exception</ExceptionType>
<StackTrace/>
</Error>
If you are using any db , please check connection string also
When I copied my solution from my pc to another one I had to change the connection string in web.config file.
Even if you have the same database name, you should do it for the server name as well.