Devart dotConnect Express for Oracle Connection with service name - c#

I have the version 9.1.131.0.
I want to connect to a Oracle 12 DB with a Service Name.
I have the login, pw, server, but it seems i can't add a service name or port to OracleConnectionStringBuilder.
How do i connect to my db with a service name?
I can make it happen with Oracle.ManagedDataAccess but due to performance issues i want to test if the Devart Driver is working better.
kind regards

Try SID instead of Service Name. I found this one: Using Direct Mode
SID** System identifier (Global Database Name)
** The Service Name connection string parameter can be used instead of SID, but in the Direct Mode you can connect only to one database instance (RAC isn't supported).
For me this works:
var str = new DbConnectionStringBuilder(false);
str.Add("Data Source", db);
str.Add("User ID", user);
str.Add("Password", pw);
var con = new Devart.Data.Oracle.OracleConnection(str.ConnectionString);
con.Open();
You can also put full connection string as data source instead of retrieving the alias from tnsnames.ora file, e.g.
string db = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST={host})(PORT=1521))(CONNECT_DATA=(SERVICE_NAME={serviceName})))";
str.Add("Data Source", db);

So this is my conclusion:
Since I don't want my users to install the Oracle Client or a install package more than 10 MB, the Devart dotConnect Express for Oracle will not work.
Quote from exception:
"Express Edition doesn't support Direct mode. Do not use Direct parameter of connection string. Refer to dotConnect for Oracle editions matrix."
Thanks for the help.
Kind regards

Related

How to connect C# .NET application to the AWS RDS Oracle account? (and SQL Developer)

Problem is simple. I have all necessary credentials from AWS console
- DB name
- Username
- password
- Endpoint
- Port
- Pulicity Accessible
...
But standard connection way (using using Oracle.ManagedDataAccess.Client;) to the database is not working.
The same is with Oracle Developer (IDE for SQL commands). I do not know how can I connect to the RDS.
Do you have some ideas? Or experience?
I assume you followed this guide to connect to the Oracle DB: http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_GettingStarted.CreatingConnecting.Oracle.html
This guide provides this example:
PROMPT>sqlplus 'mydbusr#(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=endpoint DNS name) (PORT=1521))(CONNECT_DATA=(SID=ORCL)))'>
You can store this connection descriptor in a tnsnames.ora and later use it in sqldeveloper.
tnsnames.ora example:
orcl =
(DESCRIPTION=
(ADDRESS=
(PROTOCOL=TCP)(HOST=endpoint DNS name) (PORT=1521)
)
(CONNECT_DATA=
(SID=ORCL)
)
)
(OK, this is bad habit from Amazon. Do not use "SID" use "SERVICE_NAME" instead!)
You can also extract the information from the connect descriptor and use basic connection configuration in SQLDeveloper.
BTW: Do you have an error message for us?

oracle connection string with SID in c#

Hi I have to connect to an Oracle Database( about which I know a little) using a windows application.
The windows application will not necessarily be in the same system.
I just needed the connection string.
So I Used Add connection functionality in Visual Studio 2014 to test the connection and get the string.
eedb is the SID which i read in stackoverflow question
Now using above, i was able to connect to the database using this functionality and even in my visual studio server explorer all the tables of the oracle database were showing but I needed to use the connection string in the windows application.
So I used following string:
DATA SOURCE=172.31.8.21:1521/eedb;USER ID=PDB_E_GND_R
I added password too to this string as
DATA SOURCE=172.31.8.21:1521/eedb;USER ID=PDB_E_GND_R;PASSWORD=123
when i run the application i get error.
System.Data.OracleClient.OracleException: ORA-01017: invalid username/password; logon denied.
So :
Why I am getting this error. Now some may mark this question as duplicate and even point out the answer can be found in issue stackoverflow question
Coz if this was the case I would have been unable to establish connection through add connection functionality of Visual Studio at all.
Please note: I added the reference: Oracle.DataAccess
And also for a programmer like me who has very little knowledge regarding the oracle.
How I can know which connection string I have to use for a particular oracle db.
Try the following connection string EZ connect does not seem to be so EZ
data source=(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = 172.31.8.21)(PORT = 1521)))(CONNECT_DATA =(SERVICE_NAME = eedb)));USER ID=PDB_E_GND_R;PASSWORD=123

How to resolve Azure "Windows logins are not supported in this version of SQL Server"?

I get the following error message, when I try to connect to SQL Azure.
Windows logins are not supported in this version of SQL Server
I'm using an Azure connection string. On development I'm running against SQL Server Express. This specific error is thrown when I try to fetch some data from the database.
The context that I'm using is running in a using clause, see below
function List<SomeType> GetList(string dbContextName)
{
using (MyDbContext context = new MyDbContext)
{
return context.SomeTypes.ToList();
}
}
We're using Entity Framework version 4.2, ASP.NET MVC 3 and .NET 4.0.
How can I resolve this issue?
I was using user/pass and still got the error message. But, I added this to my connection string and it worked.
Trusted_Connection=False;Encrypt=True;
Set
Integrated Security=False
In Connection String.
You've probably used the incorrect connection string, this is the connection string format that worked for my case:
"ConnectionString": "Server=tcp:xxxx.database.windows.net,1433;Database=xxx;User ID=xxx;Password=xxx;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
Integrated authentication (i.e. SSPI in the connection string) is NOT supported in SQL Azure.
Only SQL Authentication is supported (i.e. username & password in the connection string)
As already mentioned by others, only SQL Server authentication is supported in SQL Azure.
You can read more on Guidelines and Limitations with SQL Azure. As well as the Security Guidelines and limitations for SQL Azure.
You have to CREATE LOGIN by yourself in your MASTER database, then you will want to CREATE USER in your custom Azure Database. Also do not forget to execute sys.sp_addrolemember to grant some permissions to your user.
More on managing users and logins in SQL Azure can be found here.
And, at the end, you can always look at the invaluable source for connection strings.
1.**Windows Authentication** is not supported in Azure so you should go with **SQL Server Authentication**.
2.When you use SQL server Authentication you should pass User Id(Login in SQL server) and Password(Password in SQL server).
3.User Id should contain space in between should not be like UserId.
4.Trusted_Connection should be false.
The connection string in *appsettings.json* look like this:
"ConnectionStrings": {
"DBContext": "Server=ServerName;Database=DbName;User Id=loginName;Password=loginPassword;Trusted_Connection=false;MultipleActiveResultSets=true"
}

Find connection string for connecting to MySQL Server 5.1.50 using OleDbConnection

I am interested how can I find the connection string in order to be able to connect to MySQL Server 5.1.50 using OleDbConnection(C#).
I used this auto generated string (after adding new data source in Visual Studio):
server=localhost;User Id=MyID;password=MyPassword;database=MyDatabase
but I always get the same error message:
An OLE DB Provider was not specified in the ConnectionString. An example would be, 'Provider=SQLOLEDB;'.
I have tried different providers but neither of them seems to work.
Is there a reason you aren't using the MySQL .NET connector? Anyways, I think you need to add
Provider=MySQL Provider; to your connection string.
try this as your connection string:
Provider=MySQL Provider;server=localhost;User Id=MyID;password=MyPassword;database=MyDatabase;
The MySQL.NET connector fully implements the ADO.NET interface. Every command is identical to using the System.Data.SqlClient namespace.

C# CLR Assembly Query

I am creating a C# assembly for MS SQL Server 2005 for encryption/decryption.
I need to query the database in this assembly, and was wondering what the preferred method of connecting to the database is? I believe we would not want to have a username/password in the connection string.
Since the assembly is registered in MS SQL does it have some sort of quick way to access data in the database?
I'm a little bit of a newb as it related to Integrated Security or Trusted Connections.
You can use the following connection string when using CLR stored procedures:
using(SqlConnection connection = new SqlConnection("context connection=true"))
{
// ..
}

Categories