Oracle Instant Client not working C# - c#

I'm having trouble installing the oracle instant client, it won't work even though i followed the directions here http://www.oracle.com/technetwork/database/features/instant-client/index-100365.html
Here is my PATH variable http://prntscr.com/3yzql4 , as you can see the PATH has the value of a directory where instant client is located.
However, when i start a project (that uses fluent nhibernate) i get the following exception
InnerException {"System.Data.OracleClient requires Oracle client software version 8.1.7 or greater."}
at this line in code
return Fluently.Configure()
.Database(cfg)
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<ZAPOSLENIMAPIRANJE>())
//.ExposeConfiguration(BuildSchema)
.BuildSessionFactory();
I know that people are saying that ODP.NET is better, but this is for a college project and i must use this.

The exception says you need version 8.1.7 of the Oracle client. This is a very old version, that is no longer available for download, and has not been, for years.
I think you need to update your entire toolchain, to something that supports at least Oracle 11gR2, if not Oracle 12cR1.
I know you said this was for a class project, so I recommend you talk to the instructor, and ask where he suggests you get Oracle 8.1.7 client software. (Hint: The only official source is Oracle Corp., but only if you have a support contract and request it.)

Related

How to set a connection string to a local machine for Entity Framework Core?

I am currently trying myself in Entity Framework in C# and trying to do the registration/auth with Identity. I was following this guide (3:38) but when came the migration part I've got some issues.
The person in the guide uses a PostgreSQL server on some hosting to connect to it with a connection string
Host=;Port=;Database=;Username=;Password;
and connects to his hosting. I don't have any hosting machine and never worked with servers. How can I use (if I actually can) a connection string to create a database file right in my project directory?
use connetion string :
"ConnectionStrings": {
"LocalhostConnection": "Host=127.0.0.1;Password=********;Persist Security Info=True;Username=databaseUser;Database=DatabaseName",
"RemoteConnection": "Host=IP or Domain Address;Port=3432;Password=********;Persist Security Info=True;Username=databaseUser;Database=DatabaseName"
},
mean of the host here (in the test environment) is the database (postgreSQL) installed on your computer. As foad abdollahi said, the host address can be IP address or Domain name or etc. so first you must find your PostgreSQL info installed PC. for retrive this info can use this link:PostgreSQL database service
The problem was that I didn't understand how the PostgreSQL work (and not sure that I understood it actually but I found a solution)
As abdollahi commented to the question I downloaded Postgres with pgadmin4 and followed another guide
.UseNpgsql("Host=localhost;Port=5432;Database=usersdb2;Username=postgres;Password=password");
Probably not the best connection string but I am happy it works :) Thanks

What Is the Syntax for Including the Service Name in a Connection String?

I have a C# ASP.Net MVC web application. I am trying to successfully connect to an Oracle database.
I am getting a "ORA-12514: TNS:listener does not currently know of service requested in connect descriptor" error.
I do not have access to the server the database is on. But I do have access to Oracle SQL Developer, which I have installed on my machine.
In my C# code I am setting the connection string like this:
ConnectionString = "DataSource=XXX.XX.XXX.XXX/abcd,1521;User ID=userid;Password=password;";
abcd should be the service name. and 1521 is the port number.
I understand that my connection string might not be the cause of the error, but I want to rule it out. Also, I know the more proper way of doing things is probably to set the connection string in web.config and retrieve it as needed, but I am doing it this way just for ease of testing until I know I am able to connect to the database successfully.
What is weird to me, is that I was able to connect to the database using Oracle SQL Developer using the same IP address, port number, service name, username, and password I am using in my connection string.
Primarily, I would like help knowing if my connection string looks valid. If you have additional thoughts about what the issue could be, that would also be appreciated.
using this command in Oracle SQL Developer:
select sys_context('userenv','service_name') from dual;
I am able to determine that the service name I am using in my connection string is one that exists, although I guess this does not guarantee that the service is up.
I am not a DBA by any means. In fact, I am still new to .Net and web development in general, but I have been assigned to troubleshoot this issue. Any help is appreciated.
I don't recall seeing the following format
DataSource=XXX.XX.XXX.XXX/abcd,1521
as valid (which doesn't mean its not, I've just not seen it).
The more common ones I've seen are:
DataSource=XXX
where XXX is a reference to your tnsnames.ora file
DataSource=//nnn.nnn.nnn.nnn/service_name
DataSource=//nnn.nnn.nnn.nnn:port/service_name
So maybe try those variants and see how you go. There's also more definitive list of alternatives at https://www.c-sharpcorner.com/UploadFile/nipuntomar/connection-strings-for-oracle/
I ended up figuring this out. My connection string format I don't t think was correct. I changed it to be:
ConnectionString = "DataSource=XXX.XX.XXX.XXX/abcd;User ID=userid;Password=password;";
Basically, I just took off the port number. In my case, the default port was what I needed anyway. Not sure what I would have done had I needed to specify the port number.
As new to Oracle I struggled a few days finding solution to this
this article helped me alot
As of Oracle 21 c
This is my Connection string for C#
Password=dev;Persist Security Info=True;User ID=Dev;Data Source=localhost:1521/XEPDB1
Keep in mind Dev is Username which is also the Schema name for Oracle

Developing with Azure Mobile Services in a local computer[.Net backend]

I'm developing a cloud service using Azure Mobile Services, and in order to test it quickly and debug it, I want to deploy it in my local computer. I select the project, hit F5, got it running in IIS express in my local PC. I execute the cliente against my local URI address of the IIS service and when I try to insert a value, this exception appears if I try to retrieve or insert a new object:
An exception of type 'System.ArgumentException' occurred in EntityFramework.SqlServer.dll but was not handled in user code
Additional information: The database name 'TR_MyTrip_Server_ExtraData_Service]_Persons_InsertUpdateDelete' is invalid. Database names must be of the form [<schema_name>.]<object_name>.
I debugged the Initialization of the controller and found out that mobile services deploys a LocalDb instance with this connection info on the DataBase property of the ServiceContext object:
Data Source=(localdb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-MyTrip.Server.ExtraData.Service-20140731060708.mdf;Initial Catalog=aspnet-TestProject.Server.ExtraData.Service-20140731060708;Integrated Security=True;MultipleActiveResultSets=True
It is not able to find this DataBase if I try to connect with this connection string to the LocalDB via the SQL Management Studio
I'm able to access to the LocalDb instance with the SQL management studio running this command on CMD and retrieving the Connection for the LocalDB
SqlLocalDB.exe info v11.0
Eitherway, on the SQL Management Studio I'm not able to see any DataBase relating my controller of the Mobile Services. I searched on google and the only related link I found was this but is not working... Does anybody know what's happening?
Thank you so much
This is a problem when you have a project name with periods in it. Like TestProject.Server.ExtraData.Service.
To fix this, go into the web.config and edit the appsetting named "MS_MobileServiceName" taking out the periods. This is the value used as the SQL schema name for your mobile service tables in the database. It can't have periods or other special characters in it.
I generally try to make this the same as the name of the mobile service I'll deploy to, but it's not technically required.
For whatever reason, I couldn't get this working using the accepted answer. I assume this has something to do with the disclaimer in web.config which states:
After publishing to Mobile Services, these settings will be overridden by the values specified in the portal.
However, I did find another work around in the MobileServiceContext file where I replaced this line:
string schema = ServiceSettingsDictionary.GetSchemaName();
if (!string.IsNullOrEmpty(schema))
{
modelBuilder.HasDefaultSchema(schema);
}
with a simple string value modelBuilder.HasDefaultSchema('mySchema');
I imagine there's a way to influence the output of GetSchemaName() but, considering how much effort it took to resolve this problem, I am perfectly content with this solution for now.
If you've changed the MS_MobileServiceName in config to remove the periods, and you're still getting the error, you'll need to re-run the scaffolding for the Initial migration in the package manager console:
Add-Migration Initial -Force
From what I could see, the scaffolding generates an embedded .resx that still has your old schema name (DefaultSchema), and a snapshot (Target) that is referenced in the designer code. Just changing the DefaultSchema didn't solve the issue for me, but re-running the scaffolding did.
I also added Table annotations to my models, but I don't think that was the issue. And probably isn't ideal if your service is already live.

Firebird 1.5 / Asp net VS 2010 (legacy database .CDB extension)

I have an old system which generated me a database in .CDB extension (i run on Firebird-1.5.6.5026-0-Win32) and i can access this database in IBExpert to query and stuff. But i need to write an application in .NET (VS 2010 4.0 framaework) so i can read this database and access some of the data to insert into a table inside SQLServer.
I tried many things, changed the server version and other things but i now all i get is ''Cannot find fbembed.dll'' exception error while trying to open the connection. My FB server doesnt have this file since he uses the 'fbclient.dll' already.
Any thoughts on how to connect my application to this .CDB database?
(this firebird version is the same that the legacy system is running, so i used the 1.7RC firebird .net provider within this server)
The connection string used is:
<add name="FirebirdConnectionString" connectionString="User=SYSDBA;Password=masterkey;
Database=localhost:C:\temp\BD\E‌​CLECTIC.CDB;DataSource=localhost;Port=3051;
Dialect=3;Charset=NONE;Role=;Connectio‌​n lifetime=15; Pooling=false;
MinPoolSize=0; MaxPoolSize=50; Packet Size=8192; ServerType=1;"
providerName="FirebirdSql.Data.FirebirdClient"/>
Unless you really want to use Firebird embedded (which you don't as you also specify localhost), you should not specify ServerType=1, but either leave it out entirely or set ServerType=0.
As to your other problem you mention in the comments, I suggest you check if this solves it and otherwise create a new question with more information.

Odbc connection string format, not finding files

This is kind of a 'double' question that might have a single answer.
I'm working with an Odbc Connection with an AS/400, with my connection string as follows:
driver={iSeries Access ODBC Driver}; system={0}; uid={1}; pwd={2}; DefaultLibraries=*USRLIBL;
I'm able to connect to the system fine.
*USRLIBL contains all the necessary libraries from the user (which is of the type 'API only' which has access to all user libraries).
However, when I try to access certain ERP libraries, it says they can't be found, while other ones can.
So as an extremely basic walkthrough:
1. Open Connection - Query File 1 from Library A: OK! - Close Connection
2. Open Connection - Query File 2 from Library A: OK! - Close Connection
3. Open Connection - Query File 1 from Library B: Exception SQL0204 - in UserName type *FILE not found
Ok, so I added in the specific library that the ERP files would be in, making the connection string as follows, just to test the program:
driver={iSeries Access ODBC Driver}; system={0}; uid={1}; pwd={2}; DefaultLibraries=*USRLIBL, LibraryB;
But then I start getting a different problem (another extremely basic walkthrough)
1. Open Connection - Query File 1 from Library A: OK! - Close Connection
2. Open Connection - Query File 2 from Library A: OK! - Close Connection
3. Open Connection - Query File 1 from Library B: OK! - Close Connection
4. Open Connection - Query File 1 from Library A again: Exception SQL0202 - in LibraryB type *FILE not found.
So my question(s) are:
Why doesn't the odbc connectionstring DefaultLibraries=*USRLIBL not return the correct libraries? (Note: I also tested this using an iDB2Connection which in fact works fine... however, the iDB2Connection can not be deployed as it literally crashes the server)
Why does the second walkthrough throw an exception, it just seems to 'skip past' *USRLIBL after reading from LibraryB even once.
Any thoughts?
Begin Edit:
There are actually two users, DEV and PROD
The *USRLIBL gets all the necessary Libraries from the Environment itself, so if when opening the connection, it detects a localhost environment, or anything that's unsecure (plus a few other caveats), it defaults to DEV log in credentials before creating the connection. This is why the system, uid, and pwd are designated as parameters in the connection (and not just stackoverflow I-dont-want-to-give-out-data placeholders)
The *USRLIBL then pulls the necessary libraries from the API user.
To Clarify, the way it's set up does work using the iDB2 Connector, but because of the limitations of our ERP system (we think), using it with an IIS 7 server causes a catastrophic failure, so we're working with the ODBC connector.
End Edit:
You can qualify your table names as library.filename and not have to deal with any library list issues.
For more information:
Client Access ODBC: Default Libraries Setting
ODBC connection string keywords
Excerpts of the relevant parts are:
With SQL naming convention, the operating system does not perform a library list search to locate an unqualified object. If a default collection is defined, the default collection is used to resolve unqualified SQL statements.
...
With the SYS naming convention, the unqualified SQL statements go to the default collection. If there is no default collection, the current library is used. If no current library is specified, the library list is used.
...
Default Collection
A job attribute set by ODBC that determines the library used when processing SQL statements that contain unqualified SQL names. When a default collection is set all unqualified objects except procedures, functions and types must reside in the default collection, regardless of naming convention.
...
How can I get ODBC to search the library list?
As explained above, edit the ODBC data source and set system naming to SYS. The default library must be empty, or on versions older than R510, the default libraries setting must start with a comma so that no default collection is defined (for example, ",MYLIB1, MYLIB2").
Try this connection string to enable system naming and to not set a default library:
driver={iSeries Access ODBC Driver}; system={0}; uid={1}; pwd={2}; naming=1; DefaultLibraries=,*USRLIBL,LibraryB;
If anyone runs into this post and is using the IBM.Data.DB2.iSeries .NET data provider as I am, the key point taken from above was using the naming=1 and not specifying a "Default Collection". I was finally successful when using the following portion in my connection string
LibraryList= MyLibrary1,MyLibrary2,MyLibrary3,MyLibrary4;naming=1;
An alternative is to set up a separate user profile for each environment. Since the *USRLIBL is set by the job description, this would entail setting up a separate job description as well. For example:
user: WEB job desc: WEB library list: CUSTPROD, ITEMPROD, UTILITY
user: WEBTEST job desc: WEBTEST library list: CUSTTEST, ITEMTEST, UTILITY
The C# code does not change except for using the test or production user ID to authenticate.

Categories

Resources