Re: stored procedure results
From: John M Deal (johndeal_at_necessitysoftware.com)
Date: 11/19/04
- Next message: Dave Fancher: "Re: WHERE IN() with parameters"
- Previous message: jaYPee: "stored procedure results"
- In reply to: jaYPee: "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 20:07:14 -0800
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: Dave Fancher: "Re: WHERE IN() with parameters"
- Previous message: jaYPee: "stored procedure results"
- In reply to: jaYPee: "stored procedure results"
- Next in thread: jaYPee: "Re: stored procedure results"
- Reply: jaYPee: "Re: stored procedure results"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|