Jerry,
Thanks for your suggestion - and that does appear to be my problem (i just wish the
email went through the wrox list/my yahoo mail quicker because I actually already
discovered that before my origingal message even showed up).
Another thing that i changed and i think might have some bearing on the problem was
i was NOT setting the commandType property, and it was coming to sql server,
according to profiler, like this:
sp_executesql N'SELECT ....'
after i supplied the commandType = CommandType.CommandText it came across as i would
expect.
live and learn, or something.
Thanks again!
John
--- Jerry Lanphear <jerrylan@q...> wrote:
> Johnny,
>
> I think your problem is that DataReaders contain collections not scalar
> values. Therefore you need to loop through the collection of DataRows
> returned in order to get your values. I will try to sketch out some code
> for you to follow. Is "CDW..dw_Resources" how you are supposed to
> reference your data table in an SQL statement? I guess so.
>
> Instead of GetUserInformation = dr("User_ID") try this
>
> While dr.Read()
> GetUserInformation = dr("User_ID")
> End While
>
> Hope This Helps!
> Regards
>
>
>
> -----Original Message-----
> From: Johnny [mailto:mailjohnny101@y...]
> Sent: Thursday, March 06, 2003 2:35 PM
> To: ASPX_Professional
> Subject: [aspx_professional] ADO.Net/Web Service Woes
>
>
> Hello all.
>
> I'm just starting to finally dig into .net and of course, it's necessary
> to swan
> dive, instead of wading, into, because i have deadlines.
>
> Anyway - i'm trying to get my head around the whole web service/ado.net
> thing and
> i'm running into a goofy problem. I started very simple and got some
> ADO.Net stuff
> to work in a vb.net winform application. everything was fine. then i
> jumped the gun
> and went straight to a webservice. i created a new web service project
> (that
> supplied the sample HelloWorld method) and starting modifying that.
>
> You can find the method below. As you can see, it doesn't really do
> anything
> awkward, and actually - it works - the method, that is. the ado.net
> stuff isn't
> working. I keep getting an error that says "Invalid attempt to read
> when no data is
> present." coming from the "System.Data" library. So, okay - it can't
> read the data
> - but the problem is, this worked from a winform app - whats the problem
> here?? i
> haven't changed the connection string or anything. the exact query
> works and
> returns data in query analyzer and a vb.net windows app.
>
> i'm testing the service using the page that's automatically created when
> you browse
> to the asmx file, it finds the method just fine, i enter a value for the
> one
> parameter (which i've recently hardcoded in the query to narrow down the
> possibilities), click the Invoke button and the error i mentioned above
> appears
> (although, it is the actual result of the webservice, so the service is
> working, but
> the ado stuff isn't, because it's the ado error that's being returned in
> xml
> webservice format).
>
> any and all suggestions/thoughts/comments extremely welcomed!
>
> Thanks,
>
> John
>
> <WebMethod()> Public Function GetUserInformation(ByVal lItemID As
> Integer) As
> String
>
> Try
> Dim strConnect As String
> strConnect = "Server=;User ID=sa;Password=;Database=CDW;"
>
> 'specify the SELECT statement to extract the data
> Dim strSelect As String
> strSelect = "SELECT User_ID FROM CDW..dw_Resources WHERE Item_ID
> = 60311"
>
> Dim cn As New SqlConnection(strConnect)
> cn.Open()
>
> Dim cmd As New SqlCommand(strSelect, cn)
>
> Dim dr As SqlDataReader
> dr = cmd.ExecuteReader()
>
> GetUserInformation = dr("User_ID")
>
> dr.Close()
> cmd.Dispose()
> cn.Close()
> cn.Dispose()
>
> Catch objError As Exception
>
> 'display error details
> GetUserInformation = objError.Message & "<br>" &
> objError.Source
> ' Exit Function ' and stop execution
>
> End Try
>
> End Function
>
>
> John Pirkey
> MCSD (VB6)
> http://www.stlvbug.org
__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/