 |
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

October 23rd, 2006, 03:49 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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.
|

October 23rd, 2006, 04:02 PM
|
Friend of Wrox
|
|
Join Date: Apr 2005
Posts: 190
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

October 24th, 2006, 12:39 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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.
|

October 24th, 2006, 10:59 AM
|
Friend of Wrox
|
|
Join Date: Apr 2005
Posts: 190
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

October 24th, 2006, 01:42 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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?
|

October 24th, 2006, 02:05 PM
|
Friend of Wrox
|
|
Join Date: Apr 2005
Posts: 190
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

October 24th, 2006, 02:14 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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?
|

October 24th, 2006, 02:29 PM
|
Friend of Wrox
|
|
Join Date: Apr 2005
Posts: 190
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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="C:\SQL Server 2000 Sample Databases\NORTHWND.MDF";Integrated Security=True;Connect Timeout=30;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
. . .
VV
|

October 24th, 2006, 02:36 PM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
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="C:\SQL Server 2000 Sample Databases\NORTHWND.MDF"
HTH
Gonzalo
|

October 24th, 2006, 02:45 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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?
|
|
 |