connecting to oracle database from c# asp.net mvc website - c#

I am trying to connect to oracle database. I am able to connect to it through a local SQL Developer tool by sticking something in the oranames.tns file.
My question is that i will be deploying this website to a number of places. A few questions:
What is the simplest way i can use to connect to this database and do very basic queries. I see some examples that have me referencing oracleclient dlls. Other methods not? Is there a best practice here?
Am i going to have to update the oranames.tns file on everyone on of the machines that i deploy to ? is there any simpler way

1.
You can use the Oracle data provider that comes with Microsoft, but I recommend using ODP.Net. It's best to use native libraries when possible since they are usually optimized better, at least in my experience.
2.
You only need to configure the tnsnames.ora on the server, because the server is what's going to be handling the DB connections, not the client PCs (assuming that this is a MVC website).

Related

Visual FoxPro data in .NET

We are in the process of migrating an old VFP application into a .NET WPF application with SQL server.
During the process we still need to read/write to the DBF files to keep our business working properly.
To do this, we use the standard OLEDB adapter that is available. However, our sysadmin is asking if we have an alternative way to access the DBF files.
Having each user connect to the files is not the best option from a network/security perspective. Specially when connecting from home through a VPN.
I've already tried to move the connection to a single server by exposing the data through an API. But that was slowing down the application too much. In some situations we synchronise the data through background jobs (Hangfire implementation). But this can be time consuming to implement.
Has anybody used any other techniques to do something similar while migrating a VFP application?
OLEDB is still the best option. Within the application, you could impersonate a specific user that has access to files.
Also Sybase Advantage Server can connect and work with VFP data files. Local mode is (was) for free and server mode paid. You might try checking that too.
Locate data on single PC as server. Access via RDP - kludges available to support multiple connections. Increase security if needed by connecting over VPN - then RDP.

AS / 400 connection method

I have to create architecture and procedures to connect Visual Studio c# programs with the database on the IBM AS/400.
I'm looking for different possibilities, I think that services Rest is the best choice but I have not yet decided how to connect them with the AS / 400.
Does anyone have experience about this? Could Entity Framework be a valid option? What about IBM.Data.DB2.iSeries data provider?
I've to do "simple" CRUD operation, i'm in a local network without permission problems or users limitations.
From my experience, you need to install the ODBC drivers of the AS/400 in order to be able to establish a connection between the application and the database. I have not tried to use Entity Framework with an ODBC driver, but this link says that Entity Framework does not support ODBC connections. Your option here is to use the OdbcClient classes offered in .NET, in order to establish the connection between your application and the AS/400 database.
REST or SOAP or ODBC or others could be "best" for different uses and different clients. In most programming categories, there is no such thing as "best" until all significant requirements and constraints are known.
Please clarify what the objectives are. Are you looking only for database interoperability? (What kinds of actions?) Is this also application 'command & control' that invokes remote application functions? What things need to happen? How does networking fit in? Who are the users?
The more elements you can consider, the better chance of getting something right.

SQL server and c# applications over network

I created a C# application that uses .mdf database and it works perfectly on my PC.
Now i wanted to install that application on network PCs that can connect to a single database and use that data.
I tried changing the connection string in application with only changing file path, but it doesn't work. How can i use one PC as server and use program as client application that can connect over network. How do i set up SQL server on that PC, and should i do that? How is this done? I couldn't find any tutorial so far...
Could someone help me a bit.
I don't think you should be doing this, this is something that I once looked into myself. I once used a standard base unit for this same purpose and although it worked fine your not really supposed to do it.
You have to ask yourself how important the application is to the business. If its critical then this would be a real bad move for a couple of reasons :-
1) What happens if base unit hosting SQL Server dies? or is switched
off. Your unstuck.
2) You will only be able to schedule backups of the
SQL Server Database on the local hard disk . If the Disk dies then you
will lose everything.
When all is said and done, for the scenario that you are presenting, a MS Access database is probably a cleaner way to go. Access databases, albeit dated, can be hosted on a shared network space and can be accessed by multiple users. ADO.NET is nt too bad and you can still use LINQ with Data Tables etc.
What your looking into doing in your description wont really be fruitful unless your hosting the SQL Server on an Actual Server, as its designed for.
Some people suggest using using SQL Compact, but that itself is designed only to run from a local machine.
Hope this Helps.
#Milan: Go to the SQL Server configuration manager and enable TCP/IP service for SQL Server. As sql server uses TCP/IP for communication.
This link will help you.
http://kristofmattei.be/2010/06/21/enabling-sql-server-2008-r2-access-over-network/

Windows Form App - Which database type should I use?

I'm hoping someone can help me. I recently started the development of a windows form application connecting to a remote sql server database. I was happy enough developing it until a potential client queried if they would be able to buy the whole application but they do not want the application connecting to the db via the internet.
I predominantly develop websites using php/mysql but migrated to c# for this particular project. I'm familiar with sql but not sure what database I should be using if the client wishes to have the whole application on their own computer. I've considered providing the database install as a pre-requisite when publishing the app (although I'm currently not sure how to do that) but I'm having reservations whether that is suitable or could lead to more problems. I want to create an application that can install to a single computer and has little to no need for administration. Could someone advise the best way to approach the data storage in this instance.
Because you have already a SqlServer database operating on your remote site, the best path should be to use the LocalDB version of SqlServer Express 2012. See this link about deployment.
If you don't use stored procedures, views and triggers then also the SQL CE could be an option, but you will not have file binary compatibility and you should work on importing your schema and data.
SQL CE is a compact light weight way of going..
http://blogs.msdn.com/b/sqlservercompact/archive/2011/01/12/microsoft-sql-server-compact-4-0-is-available-for-download.aspx

Windows forms application with database publishing

I'll try to keep the question simple and short - what are the best practices when publishing a windows forms application which is using a SQL Server database?
Using ClickOnce with prerequisites I can enforce SQL Server Express installation, but what if it's already installed? How do you build the connection string? How do you find the names of the instances of the server? What kind of authentication should be used - Windows or SQL? Can this process be automated or is user interaction inevitable?
Adding an answer since this is the way you decided to go anyway, glad to help :)
You could also consider using SQL Server Compact which requires no setup and runs directly in-process with your application. Of course does not offer all features of SQL Express so really depends on your needs.
Have a look at: Microsoft SQL Server Compact 4.0
Note: if you could easily get rid of your triggers either you have cut functionalities or you got rid of things you do not really needed. I am old school and never use triggers, they are ofthen misused, seen people creating triggers just to set a default value in a column because did not know could have used the default.
Hmm, in this scenario I would say you would have to take into account the use of the database, if the database is connected up to a network which will support many users authentication would be needed and would inevitibly face some kind of user interaction.

Categories

Resources