473,698 Members | 2,628 Online
Bytes | Software Development & Data Engineering Community
+ 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=localhos t;Integrated
security=SSPI;d atabase=master" );

But I get an exception:
ServerVersion 'myConn.ServerV ersion' threw an exception of type
'System.Invalid OperationExcept ion' string
{System.Invalid OperationExcept ion}
base {"Invalid operation. The connection is closed."}
System.SystemEx ception {System.Invalid OperationExcept ion}

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 13805

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=mymachin ename\SqlExpres s;Integrated
security=SSPI;d atabase=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.co mwrote in message
news:11******** **************@ h3g2000cwc.goog legroups.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=localhos t;Integrated
security=SSPI;d atabase=master" );

But I get an exception:
ServerVersion 'myConn.ServerV ersion' threw an exception of type
'System.Invalid OperationExcept ion' string
{System.Invalid OperationExcept ion}
base {"Invalid operation. The connection is closed."}
System.SystemEx ception {System.Invalid OperationExcept ion}

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
2751
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 place (System32 or php folder and few more folders just to be sure) including ntwdblib.dll
0
1386
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 Li (likong@email.com)
2
15665
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 File(?) I want to access. Here is my problem: Normally to access a linked sever I would do the following: select * from ServerName.DatabaseName.dbo.TableName
3
5129
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. When i try to connect to a server that doesnt exist it raises a "Connection forcibly rejected by the resmote host" SocketException.
3
4316
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 #1 MSSQL 2000 sp4 Windows 2000 Server PHP4 on IIS5 (CGI)
2
4951
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 method may succeed one time and not another. I cannot find any reason why it would work one time and not another. The exception occurs every two or three calls to the web method. The service utilizes a COM component provided by PeopleSoft...
9
5838
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 connect. I've trawled the net for hours looking for code, has anyone got any that definately works, or just a simple way I can check the connection. Thanks
1
1650
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 have that computer's IP address(say,123.456.789.000),and the username and password.But when i try to connect to the server ,I get the following error: Cannot connect to 123.456.789.000\sqlexpress An error has occured while establishing a...
10
4088
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 Source=.\SQLEXPRESS;Initial Catalog=quiz;User ID=factory1;Password = 123;"; var ConnectObj = Server.CreateObject("ADODB.Connection"); var RS = Server.CreateObject("ADODB.Recordset"); var sql="select * from .dbo.Question"; ...
0
9170
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9031
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8902
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8873
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7740
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6528
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4623
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2339
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.