473,466 Members | 2,016 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Exception when connecting to MsSQL server

Hi,

I like to develope an application which uses a MsSQL database. I
believe that C# works really well with MsSQL. To start with, I'd like
to host the sql server locally on my machine as I develop, but later
I'd like to be able to host it on a server and have multiple instances
of the application access the server.
I have installed SQL Server 2005 Express Edition on my machine but was
never prompted for a user name or anything like that. I attempt to
connect to the server using -

SqlConnection myConn = new SqlConnection("Server=localhost;Integrated
security=SSPI;database=master");

But I get an exception:
ServerVersion 'myConn.ServerVersion' threw an exception of type
'System.InvalidOperationException' string
{System.InvalidOperationException}
base {"Invalid operation. The connection is closed."}
System.SystemException {System.InvalidOperationException}

Can anyone explain to my what is wrong. Perhaps I have to configure
the installation of SQL Server but I'm not sure.

Thanks,

Barry.

Mar 7 '07 #1
1 13778

Usually, when the express edition is installed, you have an "Instance" name.

so localhost would be wrong in this scenario.

Try:
SqlConnection myConn = new
SqlConnection("Server=mymachinename\SqlExpress;Int egrated
security=SSPI;database=master");
Or do a google search for how the sqlexpress edition connection string is
formed.

...

The reason? InstanceNames allow more than 1 version (or instance) of sql
server to be installed on the same computer, thus you need a way to
differeniate them.


<bg***@yahoo.comwrote in message
news:11**********************@h3g2000cwc.googlegro ups.com...
Hi,

I like to develope an application which uses a MsSQL database. I
believe that C# works really well with MsSQL. To start with, I'd like
to host the sql server locally on my machine as I develop, but later
I'd like to be able to host it on a server and have multiple instances
of the application access the server.
I have installed SQL Server 2005 Express Edition on my machine but was
never prompted for a user name or anything like that. I attempt to
connect to the server using -

SqlConnection myConn = new SqlConnection("Server=localhost;Integrated
security=SSPI;database=master");

But I get an exception:
ServerVersion 'myConn.ServerVersion' threw an exception of type
'System.InvalidOperationException' string
{System.InvalidOperationException}
base {"Invalid operation. The connection is closed."}
System.SystemException {System.InvalidOperationException}

Can anyone explain to my what is wrong. Perhaps I have to configure
the installation of SQL Server but I'm not sure.

Thanks,

Barry.

Mar 7 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: stefanPL | last post by:
Hello, well, I am still trying to connect to SQL Server 2000 (MSDE) form PHP I did the following: 1. enabled php_mssql.dll extension in php.ini (phpinfo() shows it) 2. every dll is in proper...
0
by: Kong Li | last post by:
Follow up to this thread, the latest Oracle 9i release 2 patchset (9.2.0.5) fixed the handle count leak problem. The problem is in Oracle client component. Thanks. Kong ----- From: Kong...
2
by: Pippen | last post by:
I'm currently trying to access data from a Cache DB using MSSQL. I have linked the Cache server through an ODBC connection. I can see in the Linked Server expansion all the tables in Cache for the...
3
by: David | last post by:
Hi, Ive been trying to work this out for the past 2 days now and im not getting anywhere fast. The problem i have is that i am using Asynchronous sockets to create a Socket Client library....
3
by: gharmel | last post by:
I'm trying to get some clues on why I get (much) slower responses from my PHP applications when dealing with a remote sql server as opposed to a local sql server. Here's my situation: Server...
2
by: Richard Collette | last post by:
Hi, I have a service, that runs perfectly when executed outside of the web service environment. When called as a web service I get the exception listed below sporadically. A call to the web...
9
by: Advo | last post by:
Im having major problems trying to connect to a mssql database thats hosted on our server. I've got the ip, username, password and database name, yet no matter what i try, I cant seem to...
1
by: SayamiSuchi | last post by:
Hi.. I have been assigned to make a database in some remote machine.The machine has MSSQL 2005.I need to connect to that remote machine's sql server via my pc using my SQL Management express.I do...
10
by: khalid galal | last post by:
Hi, i am having a problem with connecting ASP with MSSQL SEVER 2005 EXPRESS EDITION, i am writing ASP code using javascript. look at this peace of code: var myConnect = "Provider=SQLNCLI;Data...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.