Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional 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
  #11 (permalink)  
Old October 23rd, 2006, 03:49 PM
Imar's Avatar
Wrox Author
Points: 72,038, Level: 100
Points: 72,038, Level: 100 Points: 72,038, Level: 100 Points: 72,038, Level: 100
Activity: 50%
Activity: 50% Activity: 50% Activity: 50%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,080
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Right, I see now. Take a look at this:

conn.ConnectionString = "<%$ ConnectionStrings:NORTHWNDConnectionString %>"

You're mixing up code behind code (in .cs and .vb files) with embedded expressions that you can use in the markup of a page.

<%$ ConnectionStrings:NORTHWNDConnectionString %> is expression syntax that can only be used in the markup (the tag based portion of an ASPX page). To access the connection strings from code, try this instead:

conn.ConnectionString = _
    ConfigurationManager.ConnectionStrings("NORTHWNDCo nnectionString ").ConnectionString

Look into the ConfigurationManager class at the MSDN site for further details about accessing connections (and other app settings) from the web.config file.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
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.
  #12 (permalink)  
Old October 23rd, 2006, 04:02 PM
Friend of Wrox
 
Join Date: Apr 2005
Location: Fort Walton Beach, FL, USA.
Posts: 190
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Uh oh, still blows up. Code below.

    <WebMethod()> _
    Public Function GetCustomers() As DataSet
        Dim conn As New SqlConnection
        Dim myDataAdapter As SqlDataAdapter
        Dim myDataSet As DataSet
        Dim cmdString As String = "SELECT * FROM Customers"
        conn.ConnectionString = _
            ConfigurationManager.ConnectionStrings("NORTHWNDCo nnectionString ").ConnectionString
        myDataAdapter = New SqlDataAdapter(cmdString, conn)
        myDataSet = New DataSet
        myDataAdapter.Fill(myDataSet, "Customers")
        Return myDataSet
    End Function

At run time it issues error msg: HTTP 500 Internal server error (IE6) when attempting to execute the line: "conn.ConnectionString .... "

VV


  #13 (permalink)  
Old October 24th, 2006, 12:39 AM
Imar's Avatar
Wrox Author
Points: 72,038, Level: 100
Points: 72,038, Level: 100 Points: 72,038, Level: 100 Points: 72,038, Level: 100
Activity: 50%
Activity: 50% Activity: 50% Activity: 50%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,080
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Do you get a more detail error message in the browser?? What happens when you test the service in your browser by browsing to it?

Otherwise, try assigning a connection string directly. That way, you can see that things at least work like they are supposed to:

conn.ConnectionString = YourConnectionStringHere
Quote:
quote:This is my first web service and I'm trying to do it without spending hours going thru a book on web services. Seems like my shortcut approach is not going to cooperate, so I am going to turn to line 1, page 1 of the book and follow it. Hopefully, all will become clear as I go thru the book.
How about at least skimming through the first couple of chapters? That gives you at least some idea about how web services operate, and can minimize the frustration and learning curve you're experiencing now.....

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
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.
  #14 (permalink)  
Old October 24th, 2006, 10:59 AM
Friend of Wrox
 
Join Date: Apr 2005
Location: Fort Walton Beach, FL, USA.
Posts: 190
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar:
Your questions:
1. The error message I posted was everything that I got.
2. I can't test the service since I can't get it to open the connection to the database.

I've secured a website for development purposes and will do further implementation using that real live server instead of local simulations.

I didn't mean to mislead you as I have apparently. I have written and used web services successfully before. That exercise was in a learning book over a year ago. It used a database that I no longer have. I could go retrace and reinstall that process but was hoping to discover some simple litle thing that would fix the current problem.

I bought a book to explain and learn and go into some detail of web service development -- that's the one I am going to have to dive into.

But all is not lost. I have changed the basic design of the project I am working on so that the data access tier will be heavily comprised of web service calls. This will allow for a much wider functionality than I had previously planned on. Also makes the project much more scalable. So it means that I will have to get into web services heavily and that will require delving into the nooks and crannies. So it was inevitable. Thanks for your help.

Victor Victor


  #15 (permalink)  
Old October 24th, 2006, 01:42 PM
Imar's Avatar
Wrox Author
Points: 72,038, Level: 100
Points: 72,038, Level: 100 Points: 72,038, Level: 100 Points: 72,038, Level: 100
Activity: 50%
Activity: 50% Activity: 50% Activity: 50%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,080
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Quote:
quote:2. I can't test the service since I can't get it to open the connection to the database.
Sure you can. Just right-click the web service in the Solution Explorer and choose View in Browser. This brings up a test form where you can test out the service. The error messages you get there are often a bit more verbose than a generic HTTP error in the communication process between the web service and the consuming client.

Good luck with this project.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
While typing this post, I was listening to: Tomb Of The Boom by Big Boi feat. Konkrete, Big Gipp & Ludacris (Track 11 from the album: Speakerboxxx) What's This?
  #16 (permalink)  
Old October 24th, 2006, 02:05 PM
Friend of Wrox
 
Join Date: Apr 2005
Location: Fort Walton Beach, FL, USA.
Posts: 190
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar:
Tried your suggestion but get the result I mentioned before, i.e., HTTP 500 Internal server error IE "The page cannot be displayed."

OK on the test form(s).
First form says: fta web service
 Get Customeres <--link button to click, causes
Second form which says: Get Customers
   Test To test the operation using the HTTP Post protocol click the Invoke button.
    Invoke <-- button.

When I click the Invoke button the next thing is:
The page cannot be displayed

HTTP 500 Internal server error.


VV


  #17 (permalink)  
Old October 24th, 2006, 02:14 PM
Imar's Avatar
Wrox Author
Points: 72,038, Level: 100
Points: 72,038, Level: 100 Points: 72,038, Level: 100 Points: 72,038, Level: 100
Activity: 50%
Activity: 50% Activity: 50% Activity: 50%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,080
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Have you tried disabling "friendly" http errors in your browser?

In IE, choose Tools | Internet Options | Advanced and then in the Browsing category disable the Show friendly HTTP error messages.

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
While typing this post, I was listening to: Cocteau (Prothese) by Front 242 (Track 1 from the album: Geography 2) What's This?
  #18 (permalink)  
Old October 24th, 2006, 02:29 PM
Friend of Wrox
 
Join Date: Apr 2005
Location: Fort Walton Beach, FL, USA.
Posts: 190
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar:
Well!! We're making some progress but no joy just yet. I unchecked friendly HTTP error msgs as suggested and ran. Got the line below: (System.NullRef..)


System.NullReferenceException: Object reference not set to an instance of an object.
    at Customers.GetCustomers() in C:\Choctaw\Website8\App_Code\Customers.vb:line 22

Below are extracts of the relevant code.


Customers.vb:line 22 conn.ConnectionString = _
            ConfigurationManager.ConnectionStrings("NORTHWNDCo nnectionString ").



<configuration>
    <appSettings/>
    <connectionStrings>
        <add name="NORTHWNDConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=&quot;C:\SQL Server 2000 Sample Databases\NORTHWND.MDF&quot;;Integrated Security=True;Connect Timeout=30;User Instance=True"
            providerName="System.Data.SqlClient" />
    </connectionStrings>

. . .


VV



  #19 (permalink)  
Old October 24th, 2006, 02:36 PM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

excuse that i pop in.. but i supposed that your web.config has something like

AttachDbFilename='C:\SQL Server 2000 Sample Databases\NORTHWND.MDF'

and not

AttachDbFilename=&quot;C:\SQL Server 2000 Sample Databases\NORTHWND.MDF&quot

HTH

Gonzalo
  #20 (permalink)  
Old October 24th, 2006, 02:45 PM
Imar's Avatar
Wrox Author
Points: 72,038, Level: 100
Points: 72,038, Level: 100 Points: 72,038, Level: 100 Points: 72,038, Level: 100
Activity: 50%
Activity: 50% Activity: 50% Activity: 50%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,080
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Or better yet, leave out the quotes altogether because you don't need them.

That said, check the way you name the connection string. There is an additional space after the name:

ConfigurationManager.ConnectionStrings("NORTHWNDCo nnectionString ").

should be

ConfigurationManager.ConnectionStrings("NORTHWNDCo nnectionString")

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
While typing this post, I was listening to: Even Stil by Brainpower (Track 2 from the album: Even Stil) What's This?
 


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
Remote Desktop Connection hari raghav Windows Server 3 June 9th, 2008 12:46 PM
SQL remote connection gcharri SQL Server 2000 0 March 26th, 2008 03:42 PM
sqlserverexpress raktol SQL Server 2005 3 October 8th, 2006 12:11 PM
Remote database connection tdaustin Classic ASP Databases 0 November 28th, 2005 11:28 PM
creating a remote connection Adam H-W SQL Server 2000 1 February 10th, 2005 08:33 AM



All times are GMT -4. The time now is 05:45 PM.


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