Showing posts with label sqlexpress. Show all posts
Showing posts with label sqlexpress. Show all posts

Friday, February 17, 2012

Connecting Visual Studio to remote SQLExpress

Hello all,

I've been trying to find an answer to this to no avail. I'm not even sure if its possible. I like to do development at home in addition to work, like most of you do. Since it is my home computer, I like to play games, so I try to keep applications to a minimum. I would like to install sqlexpress on a virtual machine (which I have successfully done), and I can connect to it via Management Studio on my local machine (non-vm). Is there a way to set visual studio to use this connection as opposed to local host? I really do not want to load sqlexpress on my local machine and have yet another thing tying up system resources.

Your feedback is appreciated.

Barret

Visual Studio should use the same connection process (string) as SSMS.

Also, you have VM tying up resouces that are not then available to SQL or VS. Using a VM is an excellent way to constrain and protect various environments -as long as you clearly realize that you are consuming both VM and Client resouces. It is a small price for the compartmentalization, and has a performance hit. Often worth the performance hit, but use caution when setting benchmarks and performance timing...

|||

The answer to the VS question is Yes and No.

If you are writing code to make a manual connection to SQL Express, you can happily use the copy of SQL Express on the VM. Make sure you have correctly enabled it for remote connectons since you are technically connecting to a different computer. If you are trying to work with the database integration features of VS that allow you to create database direclty in your project and work with them using User Instances, then you can not use the copy on your VM. User Instances are only supported via local connections, there is no way to configure VS to use a remote copy of SQL Express to support that.

Mike

|||Thanks Mike!

Not the answer I was hoping for, but it is the answer I needed :)

Thanks again,
Barret

Connecting Visual Studio to remote SQLExpress

Hello all,

I've been trying to find an answer to this to no avail. I'm not even sure if its possible. I like to do development at home in addition to work, like most of you do. Since it is my home computer, I like to play games, so I try to keep applications to a minimum. I would like to install sqlexpress on a virtual machine (which I have successfully done), and I can connect to it via Management Studio on my local machine (non-vm). Is there a way to set visual studio to use this connection as opposed to local host? I really do not want to load sqlexpress on my local machine and have yet another thing tying up system resources.

Your feedback is appreciated.

Barret

Visual Studio should use the same connection process (string) as SSMS.

Also, you have VM tying up resouces that are not then available to SQL or VS. Using a VM is an excellent way to constrain and protect various environments -as long as you clearly realize that you are consuming both VM and Client resouces. It is a small price for the compartmentalization, and has a performance hit. Often worth the performance hit, but use caution when setting benchmarks and performance timing...

|||

The answer to the VS question is Yes and No.

If you are writing code to make a manual connection to SQL Express, you can happily use the copy of SQL Express on the VM. Make sure you have correctly enabled it for remote connectons since you are technically connecting to a different computer. If you are trying to work with the database integration features of VS that allow you to create database direclty in your project and work with them using User Instances, then you can not use the copy on your VM. User Instances are only supported via local connections, there is no way to configure VS to use a remote copy of SQL Express to support that.

Mike

|||Thanks Mike!

Not the answer I was hoping for, but it is the answer I needed :)

Thanks again,
Barret

Tuesday, February 14, 2012

Connecting to wrong SQL Server

I have a machine where I have installed Visual Studio 2005 including SQLExpr
ess. I have also installed MSDE2000. They are both named instances:
MyMachine\SQLExpress and MyMachine\S3MSDE.
Locally everything works fine. But when I connect to MyMachine from an other
machine with the connectstring containing '...Data
Source=MyMachine\S3MSDE,1234;...' I always end up beeing connected to the SQ
LExpress instance of SQL Server.
WHY?
ToschIt looks like you are always connecting to the default port. Try starting
the SQL Server Browser Service on MyMachine. It is the browser service that
resolves the name to the correct port.
--
Rick Byham
MCDBA, MCSE, MCSA
Documentation Manager,
Microsoft, SQL Server Books Online
This posting is provided "as is" with
no warranties, and confers no rights.
"Tosch" <tosch_nospam@.swissonline.ch> wrote in message
news:o50292l98e45ugu0j7cej427gm5qeaj5ju@.
4ax.com...
>I have a machine where I have installed Visual Studio 2005 including
>SQLExpress. I have also installed MSDE2000. They are both named instances:
> MyMachine\SQLExpress and MyMachine\S3MSDE.
> Locally everything works fine. But when I connect to MyMachine from an
> other machine with the connectstring containing '...Data
> Source=MyMachine\S3MSDE,1234;...' I always end up beeing connected to the
> SQLExpress instance of SQL Server.
> WHY?
> Tosch
>|||It looks like you are always connecting to the default port. Try starting
the SQL Server Browser Service on MyMachine. It is the browser service that
resolves the name to the correct port.
--
Rick Byham
MCDBA, MCSE, MCSA
Documentation Manager,
Microsoft, SQL Server Books Online
This posting is provided "as is" with
no warranties, and confers no rights.
"Tosch" <tosch_nospam@.swissonline.ch> wrote in message
news:o50292l98e45ugu0j7cej427gm5qeaj5ju@.
4ax.com...
>I have a machine where I have installed Visual Studio 2005 including
>SQLExpress. I have also installed MSDE2000. They are both named instances:
> MyMachine\SQLExpress and MyMachine\S3MSDE.
> Locally everything works fine. But when I connect to MyMachine from an
> other machine with the connectstring containing '...Data
> Source=MyMachine\S3MSDE,1234;...' I always end up beeing connected to the
> SQLExpress instance of SQL Server.
> WHY?
> Tosch
>|||ok, since I changed the port number to the port number msde2000 uses everyth
ing works fine. Apparently if you add the port number the name of the
sqlserver/instance doesn't seem to matter.
Tosch
On Thu, 15 Jun 2006 08:05:26 -0700, "Rick Byham [MS]" <rickbyh@.online.mi
crosoft.com> wrote:

>It looks like you are always connecting to the default port. Try starting
>the SQL Server Browser Service on MyMachine. It is the browser service that
>resolves the name to the correct port.|||ok, since I changed the port number to the port number msde2000 uses everyth
ing works fine. Apparently if you add the port number the name of the
sqlserver/instance doesn't seem to matter.
Tosch
On Thu, 15 Jun 2006 08:05:26 -0700, "Rick Byham [MS]" <rickbyh@.online.mi
crosoft.com> wrote:

>It looks like you are always connecting to the default port. Try starting
>the SQL Server Browser Service on MyMachine. It is the browser service that
>resolves the name to the correct port.

Connecting to the SQLEXPRESS on your computer

How do I connect to the SQLEXPRESS installed on my computer without network connection (as a standalone computer)?

Thanks.

hi,

local connections are usually performed via shared memory, so you do not require network protocols to be enabled to connect to a local instance..

what kind of problems are you experiencing? you usually generate a connection string like those provided in http://www.connectionstrings.com/, thus something similar to

Data Source=(Local)\NamedInstanceName;Initial Catalog=the_database;Integrated Security=SSPI;

regards

|||

I was having problems connecting to my local PC even after creating a security user and using the correct connection string. Turns out that I needed to go into SQL Server Configuration Manager and enable TCP/IP Protocol. Everything was disabled by default. Start, All Programs, Microsoft SQL Server 2005, Configuaration Tools, SQL Server Configuration Manager (local), SQL Native Client Configuration, Client Protocols, Right Click TCP/IP and select properties to enable.

|||

Hi Cecook,

You were probably connecting through MDAC. This is fine and fully supported, but you do have to enable TCP/IP in order to connect with legacy providers. If you use the new SQL Native Client (SNAC) you can connect directly to SQL using Shared Memory and you don't need to enable TCP/IP for local connections. SNAC also supports ODBC and OLEDB as well.

Note: You always have to enable TCP/IP or Named Pipes to connect to SQL from a remote client.

Mike

Connecting to SQLExpress from classic ASP.

Migrating a site to a new server. Moved data to SQLExpress. Changed connection string to point to SQLExpress and now I am getting this error.

Microsoft OLE DB Provider for SQL Servererror '80004005'

Cannot open database "PHCSQL" requested by the login. The login failed.

/func/inc_DatabaseFunctions.inc, line 5
Do I need to do permissions differently than MSDE?
Did connection strings change?
Help?

Hi,
Download the full eval version and install it as a named instance and register the Express. How install the full version management studio which is a separate install and right click at the top to register the Express. Then create permissions for Asp in the security section of management studio. Another option is to just restore the backup .bak file of the MSDE with the backup and restore wizard and choose the restore from a device option. Try the links below to download the eval verion and connection strings including old style connection strings. Hope this helps.

http://www.microsoft.com/sql/downloads/trial-software.mspx

http://www.carlprothman.net/Default.aspx?tabid=81

connecting to sqlexpress from classic asp

hi,

i'm using classic asp to try and connect to a sqlexpress database on a development server. i get the following error:

Microsoft OLE DB Provider for SQL Server (0x80004005)
[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.
/dbtest.asp, line 8

I'm using the following script which runs fine against a regular SQL server (version 8) on the network.

<%@.LANGUAGE="JAVASCRIPT"%>

<%
var strCon, conn, sql;

strCon = "Provider=SQLOLEDB.1;Data Source=localhost;Initial Catalog=rapidHB;User Id=rapid;Password=xxx";
conn=Server.CreateObject("ADODB.Connection");
conn.Open(strCon);

sql = "SELECT product_code FROM products WHERE product_type = 1";

var results= conn.Execute(sql).GetString();
Response.write(unescape(results));
%>

I have tried changing Data Source to servername\SQLEXPRESS, changing initial catalog to master, using a user name defined on the database and changing the provider to SQLNCLI but nothing has worked.

Anyone got any idea what I'm doing wrong? Using ASP.Net is not an option.

Rgds,

lukemack

I believe this is your problem;

Provider=SQLOLEDB.1;Data Source=localhost

Try changing to this if you took the defaults

Provider=SQLNCLI; Data Source=localhost\SQLEXPRESS

|||thanks for the reply. I;ve tried that and now get the error:

Microsoft SQL Native Client (0x80004005)
Named Pipes Provider: Could not open a connection to SQL Server [2].

My connection string is now:

strCon = "Provider=SQLNCLI;Data Source=localhost\sqlexpress;Initial Catalog=rapidHB;User ID=sa;Password=xxx";

i have checked and the named pipes protocol is enabled for sqlexpress.

any ideas?

thanks,

lukemack.

|||

Is SQL Express local or remote to the ASP machine?

Can you try switching to use TCP/IP?

|||its local. i'm running iis 5.1 on windows xp pro as a development server. how do i force a tcp/ip connection?

i can connect locally in the management console fine and remote connections are enabled. i was able to connect remotely via a management console on another machine.
|||anyone? i cant believe how difficult a simple local connection is from asp as compared to php and mysql.

i've noticed that netstat-a does not show specify a port number for sql server. the line is:

TCP lukem1:ms-sql-s lukem1:0 LISTENING

also, i get this error in the sqlserver error log:

The SQL Network Interface library could not register the Service Principal Name (SPN) for the SQL Server service. Error: 0x54b

Its stated elsewhere on this forum that this shouldnt be a problem but could this be involved?

thanks,

lukemack

|||i solved this.

instead of localhost\sqlserver or any variations thereof, i put just a "." and it works. so, for anyone else banging their head against their computer, the connection sctring should look like this:

strCon = "Provider=SQLNCLI;Data Source=.;Initial Catalog=dbName;User ID=sa;Password=xxx";

cheers,

lukemack.
|||Just so others reading the thread are clear, thsi works because you have installed SQL Express as a default instance as opposed to a named instance, this is not the norm. So the connection estring I supplied will work for named instances, yours will work for default

Connecting to sqlexpress from another machine.

I have developed an application in vs.net and have an sql express version on
one of my computers (Actually both computers).
How do I connect to this database from the other machine (workgroup, not
dedicated server)
When I try to connect through the Add Connection I get the message
'An error has occured while establishing a connection to the server. When
connecting to SQL Server 2005,
this failure may be caused by the fact under the default settings SQL Server
does not allow remote connections.
(Provider: SQL Network Interface, error: 26 -Error locating Server/Instance
Specified)'
reidarTHi
Can you connect using SQLCMD? It could be that you have not enable remote
connections with SqlSAC.exe! When you connect you should be able to specify
the machine name\Instance or the IP address\Instance in your connection
string. If you can connect using the IP address and not the hostname you may
need to add it to your hosts file.
John
"reidarT" wrote:
> I have developed an application in vs.net and have an sql express version on
> one of my computers (Actually both computers).
> How do I connect to this database from the other machine (workgroup, not
> dedicated server)
> When I try to connect through the Add Connection I get the message
> 'An error has occured while establishing a connection to the server. When
> connecting to SQL Server 2005,
> this failure may be caused by the fact under the default settings SQL Server
> does not allow remote connections.
> (Provider: SQL Network Interface, error: 26 -Error locating Server/Instance
> Specified)'
> reidarT
>
>|||reidarT wrote:
> I have developed an application in vs.net and have an sql express version on
> one of my computers (Actually both computers).
> How do I connect to this database from the other machine (workgroup, not
> dedicated server)
> When I try to connect through the Add Connection I get the message
> 'An error has occured while establishing a connection to the server. When
> connecting to SQL Server 2005,
> this failure may be caused by the fact under the default settings SQL Server
> does not allow remote connections.
> (Provider: SQL Network Interface, error: 26 -Error locating Server/Instance
> Specified)'
> reidarT
>
Use the Surface Area Configuration tool to enable remote connections...
Tracy McKibben
MCDBA
http://www.realsqlguy.com

Connecting to sqlexpress from another machine.

I have developed an application in vs.net and have an sql express version on
one of my computers (Actually both computers).
How do I connect to this database from the other machine (workgroup, not
dedicated server)
When I try to connect through the Add Connection I get the message
'An error has occured while establishing a connection to the server. When
connecting to SQL Server 2005,
this failure may be caused by the fact under the default settings SQL Server
does not allow remote connections.
(Provider: SQL Network Interface, error: 26 -Error locating Server/Instance
Specified)'
reidarTHi
Can you connect using SQLCMD? It could be that you have not enable remote
connections with SqlSAC.exe! When you connect you should be able to specify
the machine name\Instance or the IP address\Instance in your connection
string. If you can connect using the IP address and not the hostname you may
need to add it to your hosts file.
John
"reidarT" wrote:

> I have developed an application in vs.net and have an sql express version
on
> one of my computers (Actually both computers).
> How do I connect to this database from the other machine (workgroup, not
> dedicated server)
> When I try to connect through the Add Connection I get the message
> 'An error has occured while establishing a connection to the server. When
> connecting to SQL Server 2005,
> this failure may be caused by the fact under the default settings SQL Serv
er
> does not allow remote connections.
> (Provider: SQL Network Interface, error: 26 -Error locating Server/Instanc
e
> Specified)'
> reidarT
>
>|||reidarT wrote:
> I have developed an application in vs.net and have an sql express version
on
> one of my computers (Actually both computers).
> How do I connect to this database from the other machine (workgroup, not
> dedicated server)
> When I try to connect through the Add Connection I get the message
> 'An error has occured while establishing a connection to the server. When
> connecting to SQL Server 2005,
> this failure may be caused by the fact under the default settings SQL Serv
er
> does not allow remote connections.
> (Provider: SQL Network Interface, error: 26 -Error locating Server/Instanc
e
> Specified)'
> reidarT
>
Use the Surface Area Configuration tool to enable remote connections...
Tracy McKibben
MCDBA
http://www.realsqlguy.com

Connecting To SQLExpress From a VB Console Application

I've been reading through the forums and I have seen that I am not the only person to have trouble simply trying to connect to a database from VB.

Firstly I have created a console application, and from within that application I have created a simple 1 table database and added two rows of data. So I now the database is there and working.

Problem is I keep getting the following error which trying to apply a connection string to an SQLConnection object:

Message: "ExecuteReader requires an open and available Connection. The connection's current state is closed."

The code I am using is as follows:

strSQLConnection = "Data Source=.\SQLEXPRESS;AttachDbFilename=" + Chr(34) + _
My.Computer.FileSystem.CurrentDirectory.ToString() + "\MusicManager.mdf" + Chr(34) + _
";Integrated Security=True;User Instance=True"

Try
conn.ConnectionString = strSQLConnection
...
...

I know the file exists and is in the right location. Why won't SQL Express open the database?

I have successfully created Windows Applications that can connect to a database. What am I doing wrong?

Cheers,

Roy

Did you call Open() on the connection object before trying to execute a command against it?

Pablo Castro
Program Manager - ADO.NET Team
Microsoft Corp.|||Do I feel stupid or what...

That was it. Thanks.

How I missed that I do not know...

Roy|||I can't count the number of times I've forgotten to Open the DB connection or tell the DataReader to Read.

Uriel

Friday, February 10, 2012

Connecting to SQL Server 2005 Express from a Remote Machine (using Named Instance)

Hi

I have Installed Microsoft SQL Server 2005 Express (Named Instance:=01HW050876\SQLEXPRESS) in my machine (OS : Windows XP). I am using ADO in Visual Basic 6 to connect to the database. I use SQL Server Authentication to connect to ther server. It works fine if I connect from my machine. However, if i try to connect from a different machine I get the following error:

Unhandled Error [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied

Here is my connection string:

Public Const CONNECT_STRING_SQL As String = "PROVIDER=SQLOLEDB.1;SERVER=01HW050876\SQLEXPRESS;UID=user;PWD=sqlpwd;DATABASE=SalesWindow"

I have also used the Ip address

Public Const CONNECT_STRING_SQL As String = "PROVIDER=SQLOLEDB.1;SERVER=xxx.xxx.xxx.xxx\SQLEXPRESS;UID=user;PWD=sqlpwd;DATABASE=SalesWindow"

The other computer is also in the same network and I was able to ping my machine from there. I have also set the login mode of the SQLServer to Mixed mode in the registry and have added the user from the other machine to the database and have given access rights.

Could you help me to track down the problem

Many thanks in Advance
Regards
Shasur

1. Enable TCP or/and Named Pipe for the sqlexpress instance.

2. Made exception in the firewall of your sqlexpress machine, the xp machine, for the sqlbrowser service and sqlexpress instance.

You can also take a look at the following blog,

http://blogs.msdn.com/sql_protocols/archive/2006/03/23/558651.aspx

Connecting to SQL Server 2005 Express from a Remote Machine (using Named Instance)

Hi

I have Installed Microsoft SQL Server 2005 Express (Named Instance:=01HW050876\SQLEXPRESS) in my machine (OS : Windows XP). I am using ADO in Visual Basic 6 to connect to the database. I use SQL Server Authentication to connect to ther server. It works fine if I connect from my machine. However, if i try to connect from a different machine I get the following error:

Unhandled Error [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied

Here is my connection string:

Public Const CONNECT_STRING_SQL As String = "PROVIDER=SQLOLEDB.1;SERVER=01HW050876\SQLEXPRESS;UID=user;PWD=sqlpwd;DATABASE=SalesWindow"

I have also used the Ip address

Public Const CONNECT_STRING_SQL As String = "PROVIDER=SQLOLEDB.1;SERVER=xxx.xxx.xxx.xxx\SQLEXPRESS;UID=user;PWD=sqlpwd;DATABASE=SalesWindow"

The other computer is also in the same network and I was able to ping my machine from there. I have also set the login mode of the SQLServer to Mixed mode in the registry and have added the user from the other machine to the database and have given access rights.

Could you help me to track down the problem

Many thanks in Advance
Regards
Shasur

1. Enable TCP or/and Named Pipe for the sqlexpress instance.

2. Made exception in the firewall of your sqlexpress machine, the xp machine, for the sqlbrowser service and sqlexpress instance.

You can also take a look at the following blog,

http://blogs.msdn.com/sql_protocols/archive/2006/03/23/558651.aspx