How could my application on client communicate database on server - c#

I am working on windows forms application using c#.net. i have developed an application(3-tier) that uses sql database as backend. i need to deploy the database on server and my app. on client machine. but how could my application communicate with database on server. please guide me.

you need a connection string that works fine during development. On your development machine if the application is connecting fine to the database server, chances are that on your client machine, it would work as well. Sometimes, the problem occurs with the credentials that you use, that might work on the development machine but on the client it wont connect due to the lack of access rights. so you need to make sure that you give proper credentials to connect to the SQL server

You don't need to do any rocket science for this. All you need to do is on the client side use the proper connection string that can connect to a remotely installed SQL Server.

Use EntityFramework for your sql server connection for updating, inserting and deleting.
Use storedprocedures for the insert/update/delete functions.

Related

Using C# application with Mysql Database on Another Computer

I have made a C# application MySql Database attached I am going to use the Application on a different Computer. According to my Logic. The Mysql database is running on the localhost server of my first PC and I think that the localhost of the other PC will be different. So,My application Won't connect to the server - It's my Idea which may be wrong.
I have the following Questions :-
1.
How do I make a Mysql local server that will even work on another PC.
2.
Do I have to Install MySql on other PC ? If yes How can i include mysql setup in the Setup Wizard of my app.
3.
Do I have to make changes In the Code (Connection or anything).
Please Give any extra suggestion if you have about this.
You do not need to install mySQL on the computer that will have the app. that defeats the purpose of having a SQL Server
You will only need to change the connection string so instead of connecting to Localhost or 127.0.0.1 you will use the ip address of the machine that has the server installed. Connection Strings
I suggest you do some reading about networking, design patterns, and SQL or you risk building a very insecure application.

C# SQL Server: Application works with database from another pc

I have my application written in C#, it uses a SQL Server database. I have a connection to a database in my C# code, some queries to write/read from database.
Now consider following: if I want to run this app from another PC, this PC has no SQL Server, will this app work? (I assume not) If not then how can this another PC still work with database? Is there a way to programmatically create database on another PC using C# so it has a name I need, columns I need. I created my database using SQL Server Management Studio.
I guess your application works with a local server.
First of all you should check in your application at startup if there is any local mssql server running. If not, you should handle it by installing one programmatically.
Read this answer how to do this if you don't know it.
After that you have to create the database, it's tables, maybe adding user priviliges. Write a SQL script that gets started by a class that starts it.
Read this to see how to start a SQL script in C#
You can do this by setting up SQL server on another machine (server).
Set that servers authentication to SQL Server authentication (requires username and password for that SQL server Management Studio)
Change the connection string in web/App.config from your C# app to use that servers Ip address and Credentails for SQL server

How can I run an application that depends on a SQL database on another machine with SQL Server?

I have created a CRUD application that is running really well. It connects to SQL on the same machine. I want to publish my C# app and install it on another PC does not have SQL.
Is it possible to run it on that PC, without installing SQL Server on it? If so, how do I do this?
Is it possible to run it on that PC?
Without a database your application is "dead".
You have two options.
Install a sql server it this PC.
Connect to a sql server isntalled in another PC.
It's your choice.
If your project is a small one and the database is less than 4GB and you are not going to install SQL Server on every machine and your client do not have access to a Server with SQL Server then you may want to use SQL Server compact
In this case your database would be an single sdf file and you will connect to it using its path on the machine. Then the connection string would be like this:
Data Source=MyData.sdf;Max Database Size=256;Persist Security Info=False;
For more on connection string see this.
Here is the download link

Connection to MYSQL from visual c#

I'm not sure if this is the right place for this question, but here goes......I have a website that was developed in PHP using MYSQL. Now, I am wanting to write an application in Visual C# which accesses the MYSQL database, and returns data from that database to the application. I attempted this, and received the error "(xx.xxx.xxx.xx) is not allowed to connect to this MYSQL server". After some research, I found that there was a way to turn this off on the server by IP address. However, this application would eventually be distributed to other people and PC's, so I don't think this is a permanent solution. I think I could open the MYSQL database to the world, but I'm hoping for some way that I can connect to MYSQL and tell the server that I am coming from the hello world application only. Does anyone know if this is possible from Visual C# and MYSQL, or know of a secure way to connect to a remote website MYSQL database using an application that can have a dynamic IP address?
Thanks in advance!
Ramhound is right in that you need to reconfigure your server if you want to do anything like this, but if you want to connect to the server directly from the client applications, your client would need to have the password for your Mysql which is not ideal..
Instead you should set up a webservice on your database server, and use that to sent/receive data to and from the clients.

about database and remote connections

i have some questions about databases and remote connections..
i've made an application that connects to sql server db on local machine then i published the app. and installed it on other machine..
was very bad when i realised that the application won't work except that there are sql server instance on that machine.. :/
am thinking now to use access db instead of Sql Server..
but i don't know if i had to install access on every machine to make the app. work ?? or just the access db file "mdb" is enough to connect and react with data on that db ??
and if i had to install access on the pc that hold the database, do i had to install it on client mashines too in order to access the db on server with remote connection ??
answering these question will rly help me too much.
thx in advance.
No you don't have to install Access. ADO.Net will take care of connection.
Also you can use SQL Server Compact Edition. With adding some Dlls to your project, you don't need sql server installed on client machine as well.

Categories