Re: stored procedure results
From: John M Deal (johndeal_at_necessitysoftware.com)
Date: 11/19/04
- Next message: Kevin Yu [MSFT]: "Re: Expression column with nulls"
- Previous message: jongalloway_at_gmail.com: "Re: Simple T-SQL question"
- In reply to: jaYPee: "Re: stored procedure results"
- Next in thread: jaYPee: "Re: stored procedure results"
- Reply: jaYPee: "Re: stored procedure results"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 18 Nov 2004 22:36:47 -0800
I'm not sure I'll be able to help you with this, but I think for anyone
to give it a shot you're going to have to provide more detail on what
you are trying to do.
First, what kind of application are you trying to build? The answers you
get will be different depending on whether or not it is ASP.Net or
Windows Forms.
Second, what is the full scenario. You've now mentioned that you aren't
just trying to get results into a datagrid, but into a data grid whose
datasource has already been set.
Am I correct in this being your scenario? You have a form that has a
datagrid on it that is being filled from an existing dataset. You now
need to query a database to get additional data, the results of which
you somehow want to add to the existing datagrid without replacing the
data that was already there.
If this scenario is correct you need to provide one more piece of
information... where do you expect to put the results of the stored
procedure? Do you want them in the footer of the grid? Do you want to
add a column to the grid to hold the results? Will there be more than
one set of results (i.e. the new stored procedure returns one result for
each row in the original grid data)?
Finally you need to explain what you were attempting in the code sample
that you provided. Does the stored procedure return multiple results
(related to the last question after the scenario above)?
Again I don't know if I'll be able to help you on this but without more
information to work with I'm tapped out of ideas. If you provide this
information you will be more likely to get some help with this.
All that said, please forgive the lengthy email if you've already gotten
help on this from the other group that you posted it to.
Have A Better One!
John M Deal, MCP
Necessity Software
jaYPee wrote:
> Thank you for the fast reply. However I can't use data reader since
> the datagrid datasource has already been set. What I need only is to
> dump the result into the datagrid.
>
> thanks.
>
> On Thu, 18 Nov 2004 20:07:14 -0800, John M Deal
> <johndeal@necessitysoftware.com> wrote:
>
>
>>What you are doing will be problematical at best. First there is the
>>issue that each sResults statement is overwriting the previous contents.
>> Now if you want to display things in a datagrid, you could first
>>rethink the use of a datareader and fill a dataset instead. The
>>datareader is a one way optimized for reading object so you won't be
>>able to directly bind it to a datagrid, however if you retrieve your
>>results to a data grid you can bind it. Finally if you are stuck on
>>using a datareader then I'd recommend checking out this article showing
>>how to convert a datareader to a dataset:
>>
>>http://authors.aspalliance.com/stevesmith/articles/convertReadertoSet.asp
>>
>>If you follow the article you should be able to bind the resulting
>>dataset (or more specifically the created table) to the datagrid (from
>>you method you'd want to return the dataset). Oh, you didn't mention
>>what type of app you need this for, but it should work equally well for
>>ASP.Net and winforms. Hope this helps.
>>
>>Have A Better One!
>>
>>John M Deal, MCP
>>Necessity Software
>>
>>jaYPee wrote:
>>
>>>I have downloaded some source code but I want this to convert the
>>>results into datagrid.
>>>
>>> dr = cmd.ExecuteReader()
>>>
>>> '****************************************
>>> ' SHOW THE RESULTS
>>> '****************************************
>>>
>>> sResults = "CustomerID" + vbTab + "ContactName" + vbTab +
>>>vbTab + "CompanyName" + vbCrLf + vbCrLf
>>>
>>> While dr.Read()
>>>
>>> sResults = sResults + dr.Item("CustomerID") + vbTab +
>>>vbTab
>>> sResults = sResults + dr.Item("ContactName") + vbTab +
>>>vbTab
>>> sResults = sResults + dr.Item("CompanyName") + vbCrLf
>>>
>>> End While
>>>
>>> dr.Close()
>>>
>>> Return sResults
>>>
>>>Anyone know how can I put the results into datagrid?
>>>
>>>thanks in advance.
>
>
- Next message: Kevin Yu [MSFT]: "Re: Expression column with nulls"
- Previous message: jongalloway_at_gmail.com: "Re: Simple T-SQL question"
- In reply to: jaYPee: "Re: stored procedure results"
- Next in thread: jaYPee: "Re: stored procedure results"
- Reply: jaYPee: "Re: stored procedure results"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|