|
 |
C# 2005 For discussion of Visual C# 2005. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
|
 |
|
|

December 21st, 2007, 07:54 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: , , USA.
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
|
|
Remoting and SQL Server 2005 Express
Have a web service on IIS that my client code calls via the System.Runtime.Remoting subsystem. The web service trys to fetch a record from SQL Server Express 2005. Worked perfect with SQL Server 2000.
With SQL Server Express 2005, I get the following:
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
I've tried everything I can think of to confidure SQL Server 2005 for remote connections.
Anyone ever had a similar problem and fixed it?
Bob
|

December 21st, 2007, 10:31 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: , , USA.
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
|
|
I apologize for cross posting, but got desperate with a n-tier app that didn't have a clear primary forum. Anyway, I have SQL Server Express configured correctly to recieve remote calls. My problem was that I only had my connection string in my remote web.config file; I needed the local and remote connection strings in my client app.config file as well. Once there, works like its 'sposed tooo.
Bob
|

December 21st, 2007, 12:02 PM
|
 |
Friend of Wrox
Points: 16,481, Level: 55 |
|
|
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
Should the client app be connecting to the database directly? Or should this be happening thru the remote interface?
-Peter
|

December 21st, 2007, 05:02 PM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: , , USA.
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
|
|
Hi Peter,
I have it set up so that the code determines at runtime whether remoting needs to be configured or not based on the app.config file setting. The setting determines the location of a DataPortal object.
<appSettings>
<add key="PortalServer" value="http://localhost/DataPortal/DataPortal.rem" />
</appSettings>
If code finds the "PortalServer" key, remote connection.
If code finds the "TetsDB" key, direct (local) connection.
Finally got it working, though.
Best,
Bob
|

December 22nd, 2007, 08:49 PM
|
Friend of Wrox
|
|
Join Date: Jun 2007
Location: San Diego, CA, USA.
Posts: 477
Thanks: 10
Thanked 19 Times in 18 Posts
|
|
So you've fixed it? I'd be interested to know what the problem turned out to be.
-------------------------
Whatever you can do or dream you can, begin it. Boldness has genius, power and magic in it. Begin it now.
-Johann von Goethe
When Two Hearts Race... Both Win.
-Dove Chocolate Wrapper
Chroniclemaster1, Founder of www.EarthChronicle.com
A Growing History of our Planet, by our Planet, for our Planet.
|

December 23rd, 2007, 01:27 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: , , USA.
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
|
|
Turns out the operative word in the error message:
"this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections"
is 'may'.
The failure may also be caused by me writing code that forgets to initialize my connection string variable.
I needed my connection string in both my app.config and web.config files. Only had it in web.config. Just the way I have things set up. Using a DataPortal component that decides whether to connect locally or remotely at run time based on what the app.config file has to say.
I also enabled remote connections through the SQL Server Surface Area Configuration tool, and enabled TCP/IP in the SQL Server Configuration manager.
Best,
Bob
|

December 23rd, 2007, 10:23 AM
|
 |
Friend of Wrox
Points: 16,481, Level: 55 |
|
|
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
Here's an interesting Martin Fowler article I came across recently. It's a bit old, but still quite applicable. It discusses use of distributed objects. Very interesting read for anyone using remoting or the like to distribute your application.
http://www.ddj.com/architect/184414966
-Peter
|

December 24th, 2007, 03:03 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: , , USA.
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
|
|
Thanks Peter,
Everything I know about distributed objects I learned from Rockford Lhotka. I'm pretty fascinated by his Component-based, Scalable Logical Architecture (CSLA). If you havn't bumped into it, definitely check it out:
http://www.lhotka.net/cslanet
Most of my recent posts have involved trying to implement CSLA with just the Express versions of VS (C# Express and VWD), SQL Server Express, and IIS 7 on Vista.
The CSLA Framework implements complete and awesome components that support remoting/serialization, remote and local data portal access, data-binding, role-based security, business rule validation, n-level undo for business objects, batch queing, testing, everything you need for distributed programming. The framework can also be referenced by either Web or Windows interfaces, or Web Services. All ya' gotta do is write your own business objects that inherit base business classes in the framework, and write stored procedures. And design an interface, of course. Source code is available for download.
I was a little nervous that the Express Editions wouldn't support all the functionality, but amazingly they do. Pretty cool free development tools. Good for MS.
Best,
Bob
|

December 24th, 2007, 03:15 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: , , USA.
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
|
|
CSLA also supports distributed transactions through Enterprise Services. That was the final piece I got smoothed out tonight. Forgot I had to strong-name my assemblies. Alls well.
Bob
|

December 24th, 2007, 04:22 AM
|
 |
Wrox Author
Points: 72,055, Level: 100 |
|
|
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
|
|
One caveat that you need to be aware off: CSLA can't use the built-in web server that comes with Visual Studio. You probably know that as you refer to IIS, but I wanted to mention it anyway.
I know Lhotka mentions it in his book, but the first time I was stubborn and tried it anyway... ;)
Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
|
Thread Tools |
Search this Thread |
|
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |