I have an application which is using config file to connect to mssql server and odbc is created and used in the config file.
This is the line in my config file to connect to database.
<add key="ConnectionString" value="Data Source=<DSN Name>;Initial Catalog=<DAtabase Name>;Integrated Security=True"></add>
Now we are testing in Oracle,
but the above format is not connecting and I had tried many other permutations of connection string like below but so far no luck
This is same like Windows string
<add key="ConnectionString" value="Data Source=<DSN Name>;Integrated Security=True"></add>
Included my Database Name with DSN
<add key="ConnectionString" value="Data Source=<DSN Name>;Initial Catalog=<DAtabase Name>;Integrated Security=True"></add>
Included Driver and SID here
<add key="ConnectionString" value= Driver=<{Oracle in OraClient11g_home1}>;Server=serverSID;Uid=<myUsername>;password=<password>
></add>
The error I am receiving
Database setup cannot find the database mentioned in the config file
None of them are working wats the correct connection string for Oracle ?
Try DBQ= instead of Server= and PWD= instead of password=.
Attribute Server is used for the Microsoft ODBC Driver (see Connection String Format and Attributes). In Oracle the attribute is DBQ (see Using the Oracle ODBC Driver).
Related
I need to connect my Microsoft Report Builder to Oracle DB but I could not seem to find the correct connection string for Oracle.
I tried:
Specifying username and password
Data Source=MyOracleDB;User Id=myUsername;Password=myPassword;Integrated Security=no;
but it returned:
Is it saying that I need to download the Oracle driver? Or should I get the connection string for Oracle DB?
If you don't already have it, you will need the Oracle Client installed. It will include an ODBC driver. ODBC is a wrapper for the Oracle Client, not a replacement. When setting up your connection you will also need to get the connection properties from the DBA (e.g. hostname/ip address, port, service name, username and password).
See documentation here:
https://docs.oracle.com/en/database/oracle/oracle-database/19/adfns/odbc-driver.html
https://www.oracle.com/database/technologies/releasenote-odbc-ic.html
Below are my connection settings for Oracle SQL Developer with tnsnames.ora
The pattern of jdbc string required is as below :
jdbc:oracle:thin#:1521:<DATABASE_NAME>
I have tried the following :
jdbc:oracle:thin:#ServerIP:1521:test2 , jdbc:oracle:thin:#ServerIP:1521:orcl.5bfzmyo25mfutjqfmvvj0cmrya.rx.internal.cloudapp.net:test2
But it is not connecting.
Assuming that
You want to use the Oracle thin JDBC driver
The database is running on ServerIP
The database listener is running on port 1521
The service name of the database is orcl.5bfzmyo25mfutjqfmvvj0cmrya.rx.internal.cloudapp.net
your connection string should be (see the linked question for additional syntax options)
jdbc:oracle:thin:#//ServerIP:1521/orcl.5bfzmyo25mfutjqfmvvj0cmrya.rx.internal.cloudapp.net
Your app server has no idea about how you've configured your local tnsnames.ora file or your local SQL Developer connection strings. So you can't reference test2 (the name of a SQL Developer connection) or any of the tnsnames.ora entries you've created on the client machine.
I have an ASP.net web application and a database created on another computer. Now I want to run this on my computer.
I have installed SQL Server Express edition and SQL Server Management Studio on my computer and I copied database file to my SQL directory and attached it successfully through SQL Server Management Studio. Applications current connection string looks like this.
<add name="ASPNETDB"
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
What do I have to change in this to make it work? FYI I have already copied database to SQL Server Management Studio default installation directory and attached it through SQL Server Management Studio express. Also I connect to SQL Server Management Studio using this server name.
localhost\SQLExpress
If you've attached the database to your SQL Server Express instance, then you should be able to use this connection string from now on:
<add name="ASPNETDB"
connectionString="Server=.\SQLEXPRESS;Database=ASPNETDB;Integrated Security=True"
providerName="System.Data.SqlClient" />
With this, you basically tell your application
what server (instance) to connect to (.\SQLEXPRESS)
what database to use on the server (ASPNETDB - or whatever name you gave it)
to use integrated security (e.g. use your Windows credentials) to log on to SQL Server
That's all you need - SQL Server will handle all the details of dealing with data and transaction log files and all those nitty gritty jobs for you.
I have an MVC 3 app using Entity Framework that was happily hosted in Azure and talking to SQL Azure Database 2 days ago. I then had a minor schema change to the database and so dropped and re-created the database via SSMS and also published the application again as I had added the default MVC app login role controls to the site - since then I cannot get my app to connect to the database and get the following error logged in an Elmah xml file:
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=".Net SqlClient Data Provider" detail="System.Data.EntityException
I can connect to the SQL Azure Database using SSMS and when I run my application in the Azure emulator connected to the SQL Azure Database everything runs perfectly but once published it refuses to connect. Any help would be massively appreciated!
A SQL Azure connection string (using EF Model First / Database First) typically lookes like this:
<connectionStrings>
<add name="SampleEntities" connectionString="metadata=res://*/Models.SampleEntities.csdl|res://*/Models.SampleEntities.ssdl|res://*/Models.SampleEntities.msl;provider=System.Data.SqlClient;provider connection string="Data Source=tcp:abcdefg.database.windows.net,1433;Database=asdf;User ID=manager#abcdefg;Password=XXXXXX;Trusted_Connection=False;MultipleActiveResultSets=True;Encrypt=True;"" providerName="System.Data.EntityClient" />
</connectionStrings>
A SQL Azure Connection string (using Code First) typically looks like this:
<connectionStrings>
<add name="SampleContext" connectionString="Data Source=tcp:abcdefg.database.windows.net,1433;Database=asdf;User ID=manager#abcdefg;Password=XXXXXX;Trusted_Connection=False;MultipleActiveResultSets=True;Encrypt=True" providerName="System.Data.SqlClient" />
</connectionStrings>
The second connection string will also work without Entity Framework.
I believe you've published a config to Azure that does not have a correct SQL Azure server name, but rather some local/on-premise SQL server. Could this be it? Can you remote into the instance and validate correct .config and SQL Azure server?
From the error it appears that your app is not using TCP/IP to connect to your SQL Azure, but rather Named Pipes, which usually implies that the SQL Azure server name is not likely a valid TCP/IP host.
I'm having problems getting my MVC3 front end to use an Oracle 11g database to hold the user memberships.
I've been following this simple tutorial but can't get it to work.
Some things I've done so far:
Downloaded and installed the Oracle Data Provider for .NET (ODAC 11.2
Release 4 (11.2.0.3.0) )
Run the InstallAllOracleASPNETProviders.sql against the database on
the development server.
Tested the connection via SQL developer (using the TNSNames file)
with no issues.
Unable to create a connection to the database under the Server
Explorer pane is Visual Studio 2010 which seems related.
Having checked the database I can see that the "ORA_ASPNET_" tables have been created OK.
I'd appreciate a steer on where I'm going wrong as this SHOULD be easy.
The problem appeared to be related to the connection string.
I had been using the TNS names file for the connection details but this wasn't being picked up.
I modified the connection string to include the server, port and service name as follows:
<connectionStrings>
<add name="OraAspNetConnectionString"
connectionString="Data Source=svr56:1521/TCO1103;Persist Security Info=True;User ID=Ora_Asp;Password=*****;"
providerName="Oracle.DataAccess.Client="/>
</connectionStrings>
The problem creating the connection is the Server Explorer also resolved itself once I used the same details in the Data source name box.
svr56:1521/TCO1103;Persist Security Info=True;User
ID=Ora_Asp;Password=*****;