How to connect my APP to SQL Server? - c#

I have 1 PC (Windows Server 2003 + SQL Server 2008)
and 2 PCs (MS SP2 + my APP)
how I can let my APP connects to sql server 2008 on other PC My APP will connect to server to store data in SQL Server 2008 and read/delete/edit (basic operations)
what is the best way to do that?
NOTE: my APP is written in C# (.NET Platform)

Look here:
how to connect to another sql server database(server pc) in local area network
How to connect to SQL server through IP
From
Connection strings for SQL Server 2008 you have:
Connect via an IP address
Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;InitialCatalog=myDataBase;User ID=myUsername;Password=myPassword;
DBMSSOCN=TCP/IP. This is how to use TCP/IP instead of Named Pipes. At the end of the Data Source is the port to use. 1433 is the default port for SQL Server.

Related

How to connect with C# app to a SQL server database created on Google Cloud Virtual machine?

I have created a Sql Server Managment Studio database, that is on Google Cloud virtual machine. Now i have C# winform app on a remote pc, and i am trying to retrive a table from that database. Virtual machine is Windows Server 2012R2 Datacenter. SSMS on virtual machine is 2014 and SQL Server 2014.
I get error in C# saying: The server was not found or was not accesible. Error 40- could not open a connection to SQL Server.
My connection string in C# is:
String strConnection=#"Data Source="Virtual machine IP"; Initial Catalog ="db
name"; User
ID="username";Password="password";";
Also i think i could connect to database on virtual machine, using my SSMS on my remote pc. I tried using IP address of virtual machine computer(ipconfig) and used username and password that i created in a VM SSMS. Also tried windows authetication with that ip. But everything with no succes. Error: The server was not found or was not accesible.
-I have allowed remote connections in SSMS.
-Have set SSMS login mode to mixed.
-Have set firewall exceptions on virtual machine for inbound rules, port TCP 1433, port UDP 1434, application sqlservr.exe, application sqlbrowser.exe
-On virtual machine in SQL Server Configuration Manager i have enabled TCP/IP, Named Pipes, Shared Memory
-SQL Server and SQL Browser are running on virtual machine.
If anyone has any ideas what to try next, i would be delightful.
On cloud , you get the URL(connection) from the host page , not just IP address
this work perfect
example for AWS cloud ms sql :
add name='YOURNAMEConnectionString'
connectionString=" Data Source=YOUR_ACCOUNT_LINK.rds.amazonaws.com ;
Initial Catalog=;User ID=;Password=;Connect Timeout=80000 "
providerName="System.Data.SqlClient"

Remotely connect to SQL Server database

I am using Visual Studio 2013 to develop a Windows form that binds data from a SQL Server database. I want this form to connect to a SQL Server database that is on my server. To try to connect to the server, I do the following:
SQL Server Object Explorer -> Add Server -> Browse for more -> Network Servers
It does not appear in it. Even if I just type the name of the server on the server name I get error 87.
My local machine is using Windows 8, and my server is Windows Server 2012 R2 with SQL Server 2014 Express Edition with Advance Services.
Please, help me with the connection.
Edit:
On the server end I did the following
SQL Server Configuration Manager
-> SQL Server Network Configuration
-> tcp/ip-> enable -> IPALL -> TCP PORT -> 1433
windows firewall advanced settings
-> inbound -> add new rule -> port -> 1433
-> allow connections
Can you connect to the server using Management Studio? If not, check in the SQL Server Configuration Manager you have enabled TCP connection for express edition of SQL server and you have enabled remote connection (TCP port 1433) in windows firewall.
enable the IP that you want to connect
for example i'm using local host
you can use your PC IP :192.168.1.2
or you can use public IP if you have public IP

can't connect to the database server from the client

I am creating a window application with a SQL server database. The application need to be installed on a terminal server and other client machine should works with this application.
I have installed this application and SQL Server Express 2008 on server and application worked currently on server but not on client. I got an error on client machine through my application over connecting to the database on server.
Any help is appreciated.
The default installation of SQL Server Express is to allow only local connection.
See this: http://technet.microsoft.com/en-us/library/ms165718(v=sql.105).aspx

I cannot display data from sql server 2005 express on an ASP.net website running from IIS windows 7

I am using Microsoft server 2003 running sql server 2005 which I have added an asp.net website on IIs.This works perfect. I can display the website on the browser and also read information from the sql server. My problem now arises when I want to do exactly the same but with my laptop which is running sql server 2005 express on windows 7. the websites displays just fine on the localhost but when I login it gives me an error saying that it cannot read files.
So my question is that is there a difference between sql server connectionstring and sql server express connection string? or the error is not connectionstring related?
Yes, the connection string for SQL Server CE is typically different from SQL Server. SQL Server CE is "self hosted." You basically connect to a file in your app_data directory. SQL Server, in contrast, has many ways to connect to it: via TCP/IP, Named Pipes, etc.
A typical SQL Server connection string is this:
Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;
A typical SQL Server CE connection string is this:
Data Source=MyData.sdf;Persist Security Info=False;
Notice how for SQL Server CE you specify the path to your database file. For SQL Server, you typically specify the server running the SQL Server Service.
Many more examples here.

Client computer cannot connect to the database of the c# .net application

I connected my database as a (sql server database file) to mt c# .net application.
the connection string was given as a relative path. the client computer asks for sql express server, what should i do? which application should i install in the client pc?
You need to supply the correct connection string, with the database server name.
If the application is supposed to connect to a local database (on the same machine as the application), you need to install SQL Express and setup the database on the client machine.

Categories