I have a SQL Server 2008 on a server which goes out on the internet through a domain name computer.example.com, I want to develop a .net app on my PC and to connect to that database through SSMS - to create tables and so on...
And I still want a connection string which can be accessed from anywhere - I'm thinking at a http url or something like that - which will be consumed by the app.
What do I must to configure on the server so that I can connect via SSMS to the database (from my PC) and how do I get a connection string to that database?
you can use Sql Server Configuration Manager for this work. when you run this application, expand the SQL Server Network Configuration, after that you can see Protocols for sql server 2008. by click on it you can enable or disable TCP/IP.
your connection string can be like this :
connectionString="Database=DBName;Server = Server IP;Integrated Security=false;user id=sa; password=Pass;
Related
I have a Windows 10 VM with SQL Server installed on it. I made sure, that in the Sql Server Configuration Manager the SQL Server Browser is running and the TCP/IP protocol is enabled.
I'm trying to connect to the server with Entity Framework (although I'm not sure if it's relevant) and I'm getting this error:
Cannot connect to SQL Server Browser. Ensure SQL Server Browser has been started.
That's the connection string that I'm using:
Integrated Security=SSPI; Persist Security Info=False; Initial Catalog=<database name>; Data Source=<server name>
This is the error message.
I tried to restart the SQL Server service but it didn't work.
Try checking your Sql Server Configuration Manager, open the Sql Server Configuration Manager by running Windows + r > compmgmt.msc and then open Services and Application in it you will find SQL Server Configuration Manager.
SQL Server Configuration Manager
Double click on the SQL Server Services and then you will find some services there.
SQL Server Services
What I underlined is the instance name of my SQL Server, so to login, you need to specify your [HostName]\[InstanceName].
Example : My host name is LAPTOP-OOHVP7Q7
So to connect, I need to specify my hostname and instance name
So i need to type "LAPTOP-OOHVP7Q7\MSSQLSERVER2016"
In your case your Hostname is "PC", try to add your instance name that you find in your SQL Server Services.
I know how to connect to SQL server Management studio locally, the one to your desktop, Windows Authentication. Code is as below.
myconnection As New SqlConnection("data source =serverNAME01; initial catalog=ZPCD; integrated security=true")
But how do I connect to SQL server Management Studio on Windows Server 2012R2, SQL Server Authentication from my desktop ?
The computer and username for remote desktop connection to Windows Server 2012R2 are:
computerNAME01,
userNAME01
The server name, login, password and IP address to management studio (database engine) are:
Server name: serverName01
Login: sa
Password: Password01
IP: 192.167.1.21
and database name is
ZPCD
This is an example of my code, but it doesn't work.
connetionString="Data Source=192.167.1.21,1433;
Network Library=DBMSSOCN; Initial Catalog=ZPCD;
User ID=sa;Password=Password01"
Error Message:
A network - related or instance-specific error occurred while establishing a connection to SQL server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provide: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 5)
https://technet.microsoft.com/en-us/library/hh231672(v=sql.110).aspx
To enable the TCP/IP network protocol Start SQL Server Configuration
Manager. Click Start, point to All Programs, and click Microsoft SQL
Server. Click Configuration Tools, and then click SQL Server
Configuration Manager. In SQL Server Configuration Manager, in the
console pane, expand SQL Server Network Configuration. In the console
pane, click Protocols for . In the details pane,
right-click TCP/IP, and then click Enable. In the console pane, click
SQL Server Services. In the details pane, right-click SQL Server
(), and then click Restart, to stop and restart the SQL
Server service.
Remote connection string should look like so.
SqlConnection("Server=192.167.1.21\sqlinstance; DATABASE=ZPCD; Connection Timeout=5; USER ID=SA; PASSWORD=Password01")
You need to have the SQL instance, the part in the () in image below after the \ after the IP address.
Can you post this from SQL Management Studio
This is the format of the connection string I use. The format (apparently) changed in VB.NET from VS 2008 to VS 2010. When I upgraded my software from VS 2008 to VS 2010, it failed to connect to Sql Server. Took me hours to figure it out:
connectionString="server=192.168.1.1;database=MyDb;uid=sa; pwd=MyPassword" providerName="System.Data.SqlClient"
R/
Prescott ....
I built a window application in visual studio 2010. It is working fine at my computer.
if i have a pc that works with windows server 2008 and i install a sql server on it , how to make my application connect to database in the sql server that instaled in the server pc .
my pc connected to the server domain .
thanks
Assuming your application is already configured to use a Sql connection string, you'll just need to configure it for the Sql Server instance you're connecting to.
For example, if your database is called MyDatabase, and your windows server on your domain is called myserver.local, and you've installed Sql Express with the default SQLEXPRESS instance name, you could create your connection string (assuming ADO.NET) something like this:
Integrated Security=true;Initial Catalog=MyDatabase;Data Source=myserver.local\SQLEXPRESS
This configuration would be for Windows Authentication (Integrated Security=true): so your domain user accounts would need to be granted LOGIN rights on the server, and those Logins associated with USERS and ROLES in your database. If you wanted to use Sql Logins instead (generally requires extra configuration when setting up your Sql Server), there are different connection strings settings for specifying username and passwords. There are many options available for the connection strings as documented here: https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring(v=vs.110).aspx. However, with Windows Authentication the only 3 you absolutely need are the ones shown above.
You can test connectivity to your Sql Server from your PC on the network using Sql Server Management Studio, which will enable you to verify the instance name and the authentication is working as expected if you can connect to the database.
I am trying to set up a development testing server, Windows 2008 Server with IIS and SQL Server 2008 Express. The IIS and classic ASP (yeah, supporting antique projects) works fine, including connecting to remote SQL Server 2008 servers, via SQLOLEDB.
However, I fail to connect to the local SQL Server 2008 Express instance. It is installed as an instance (ie, PC-NAME\SQLEXPRESS), and user/pwd authorisation is enabled. I can successfully set up an ODBC entry, so the server works fine. The problem lies in getting the IIS-ASP-SQLOLEDB see the server and connect to it.
Simple connection string, which works on any remote SQL Server 2008 servers, fails at my local express server:
Provider=SQLOLEDB;Data Source=.\SQLEXPRESS;User ID=userName;Password=_pwd_;Database=DbName
The error I get is
SQL Server does not exist or access denied.
The server error log does not contain any trace of unsuccessful login attempt, so I assume there is some problem resolving the data source (because of the instance name?), or the server is somehow inaccessible (protocol, security settings?) from the IIS process.
In SQL Server 2008 express edition it runs on dynamic ports. The solution is just go to properties of the TCP/IP and in the TCP Port just give whatever port you want your SQL Server to listen on.
strConn = "Provider=SQLOLEDB; Network Library=DBMSSOCN; Data Source=.\SQLEXPRESS; Connection Timeout=15;Packet Size=4096; Initial Catalog=DbName; User ID=userName; Password=_pwd_;"
Can you post how you access the connection object via ASP?