Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 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
Default 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

  #2 (permalink)  
Old 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
Default

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

  #3 (permalink)  
Old December 21st, 2007, 12:02 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Should the client app be connecting to the database directly? Or should this be happening thru the remote interface?

-Peter
  #4 (permalink)  
Old 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
Default

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

  #5 (permalink)  
Old December 22nd, 2007, 08:49 PM
Friend of Wrox
Points: 1,749, Level: 16
Points: 1,749, Level: 16 Points: 1,749, Level: 16 Points: 1,749, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2007
Location: San Diego, CA, USA.
Posts: 477
Thanks: 10
Thanked 19 Times in 18 Posts
Default

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.
  #6 (permalink)  
Old 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
Default

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

  #7 (permalink)  
Old December 23rd, 2007, 10:23 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

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
  #8 (permalink)  
Old 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
Default

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

  #9 (permalink)  
Old 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
Default

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

  #10 (permalink)  
Old December 24th, 2007, 04:22 AM
Imar's Avatar
Wrox Author
Points: 72,035, Level: 100
Points: 72,035, Level: 100 Points: 72,035, Level: 100 Points: 72,035, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,079
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
.NET Remoting and SQL Server 2005 express Bob Bedell SQL Server 2005 1 December 21st, 2007 10:37 AM
Connecting to SQL Server 2005 Express Locally GM_Access BOOK: Beginning Access 2003 VBA 1 August 7th, 2007 06:34 PM
SQL SERVER 2005 STANDARD (not express) proslambano BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 8 January 8th, 2007 08:55 PM
SQL Server 2005 Express Problem asped_man BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 3 November 29th, 2005 05:07 AM



All times are GMT -4. The time now is 03:28 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.