473,769 Members | 6,126 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I show the results of a stored procedure in a datagrid?

Jim
Can someone, please, show me how to display the results of
a stored procedure in a VB.NET datagrid on a winform? I'm
a newbie.

Here's my SQL 2000 stored precedure that returns the
status of SQL Jobs as a table.

=============== =============== =============== =====
CREATE PROCEDURE [dbo].[GetRunningJobs] AS

EXEC msdb.dbo.sp_hel p_job @execution_stat us = 0

GO
=============== =============== =============== =====
Thanks,

Jim
Nov 20 '05 #1
6 2710
Create a dataadapter and assign the select query to this stored proc in your
database. Then, you could create a strongly typed dataset from this, and
assign your datagrid's datasource to your new dataset.

Peace,
cege
"Jim" <an*******@disc ussions.microso ft.com> wrote in message
news:05******** *************** *****@phx.gbl.. .
Can someone, please, show me how to display the results of
a stored procedure in a VB.NET datagrid on a winform? I'm
a newbie.

Here's my SQL 2000 stored precedure that returns the
status of SQL Jobs as a table.

=============== =============== =============== =====
CREATE PROCEDURE [dbo].[GetRunningJobs] AS

EXEC msdb.dbo.sp_hel p_job @execution_stat us = 0

GO
=============== =============== =============== =====
Thanks,

Jim

Nov 20 '05 #2
Jim
It's not a select query. I can do select queries. I can
start a stored procedure and get the single integer result
that says the procedure completed. I just can't seem to
get the returned table into a datagrid.

Jim
-----Original Message-----
Create a dataadapter and assign the select query to this stored proc in yourdatabase. Then, you could create a strongly typed dataset from this, andassign your datagrid's datasource to your new dataset.

Peace,
cege
"Jim" <an*******@disc ussions.microso ft.com> wrote in messagenews:05******* *************** ******@phx.gbl. ..
Can someone, please, show me how to display the results of a stored procedure in a VB.NET datagrid on a winform? I'm a newbie.

Here's my SQL 2000 stored precedure that returns the
status of SQL Jobs as a table.

=============== =============== =============== =====
CREATE PROCEDURE [dbo].[GetRunningJobs] AS

EXEC msdb.dbo.sp_hel p_job @execution_stat us = 0

GO
=============== =============== =============== =====
Thanks,

Jim

.

Nov 20 '05 #3
Dude...

it has to be a select query... thats how data grids work... if you want to
return a single result from a stored proc, don't use a datagrid. Thats like
using a backhoe to plant a daisy...

and if its a "returned table" then yes, thats a select query.

"Jim" <an*******@disc ussions.microso ft.com> wrote in message
news:0c******** *************** *****@phx.gbl.. .
It's not a select query. I can do select queries. I can
start a stored procedure and get the single integer result
that says the procedure completed. I just can't seem to
get the returned table into a datagrid.

Jim
-----Original Message-----
Create a dataadapter and assign the select query to this

stored proc in your
database. Then, you could create a strongly typed

dataset from this, and
assign your datagrid's datasource to your new dataset.

Peace,
cege
"Jim" <an*******@disc ussions.microso ft.com> wrote in

message
news:05******* *************** ******@phx.gbl. ..
Can someone, please, show me how to display the results of a stored procedure in a VB.NET datagrid on a winform? I'm a newbie.

Here's my SQL 2000 stored precedure that returns the
status of SQL Jobs as a table.

=============== =============== =============== =====
CREATE PROCEDURE [dbo].[GetRunningJobs] AS

EXEC msdb.dbo.sp_hel p_job @execution_stat us = 0

GO
=============== =============== =============== =====
Thanks,

Jim

.

Nov 20 '05 #4
Jim
Maybe I'm confused? Are you saying that "GetRunningJobs "
is my SELECT statment? This returns a table.

Here's where I'm getting stuck:

Dim myConn As SqlConnection = New _
SqlConnection
("server=abc;da tabase=Northwin d;integrated security=SSPI")
Dim myDA As New SqlDataAdapter

myDA.SelectComm and = New SqlCommand
myDA.SelectComm and.Connection = myConn

'-------What do I do here?
myDA.SelectComm and.CommandText = "GetRunningJobs "
myDA.SelectComm and.CommandType = _
CommandType.Sto redProcedure
'-------
' OR
'-------
myDA.SelectComm and.CommandText = "EXEC GetRunningJobs"
myDA.SelectComm and.CommandType = _
CommandType.Tex t
'--------

myConn.Open()

' Then which execute command do I use and how?
myDA.SelectComm and.??????????? ?
.ExecuteNonQuer y
.ExecuteReader
myConn.Close()
Jim

Nov 20 '05 #5
Jim
Thanks for your help. The light bulb just lit up in my
head! Here's how I got it to work:

=========
myDA.SelectComm and = New SqlCommand
myDA.SelectComm and.Connection = myConn

'Note I'm running the stored procedure through t-sql.
myDA.SelectComm and.CommandText = "Exec GetRunningJobs"

myDA.SelectComm and.CommandType = CommandType.Tex t

myConn.Open()
myDA.SelectComm and.ExecuteNonQ uery()
myDA.Fill(myDS, "Jobs")
myConn.Close()

DataGrid1.DataS ource = myDS
DataGrid1.DataM ember = "Jobs"
=========

Jim
Nov 20 '05 #6
Awesome. =) Nice job.
"Jim" <an*******@disc ussions.microso ft.com> wrote in message
news:01******** *************** *****@phx.gbl.. .
Thanks for your help. The light bulb just lit up in my
head! Here's how I got it to work:

=========
myDA.SelectComm and = New SqlCommand
myDA.SelectComm and.Connection = myConn

'Note I'm running the stored procedure through t-sql.
myDA.SelectComm and.CommandText = "Exec GetRunningJobs"

myDA.SelectComm and.CommandType = CommandType.Tex t

myConn.Open()
myDA.SelectComm and.ExecuteNonQ uery()
myDA.Fill(myDS, "Jobs")
myConn.Close()

DataGrid1.DataS ource = myDS
DataGrid1.DataM ember = "Jobs"
=========

Jim

Nov 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
7190
by: John | last post by:
Hi everyone, I have a stored procedure which I use to query a table. The first part of the stored procedure uses a cursor to update a temp table whilst the second part of the query actually retrieves information from a database table utilising information based on the temp table. My problem is that when I run the procedure, the cursors status is output and therefore becomes part of the result set. I really only want the information...
0
2654
by: Amber | last post by:
Stored procedures are faster and more efficient than in-line SQL statements. In this article we will look at two SQL Server stored procedures; one using an input parameter and one not, and see how to call them from an ASP.Net page Every modern database system has a stored procedure language. SQL Server is no different and has a relatively sophisticated and easy to use system. This article will not attempt to go into depth in explaining...
4
3001
by: Mike Dinnis | last post by:
Hi, I've been working through a number of turorials to try to learn more about retrieving data from a SQL database. I think i've mastered techniques where i create a sql string in the page and pass it to the Db and retrieveing data from a stored procedure, but I can't get the hang of parameters. I have a method where I can get the parameters passed to the sp but it doesn't want to return any results. Here's a copy of my code:
0
1906
by: Rob | last post by:
I doubt this is the best way to do it, but what I came up with was to hide the XML in an HTML Comment then edit the file deleting the HTML stuff and keep the XML results. If anyone has a better solution, I would be interested. Thank you. Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim cmd As System.Data.SqlClient.SqlCommand cmd = New System.Data.SqlClient.SqlCommand
2
2239
by: Max | last post by:
Is it possible or more effecient to use a stored procedure to populate a datagrid when using datagrid or custom paging? Is it (ADO.NET?) pulling the entire table into the dataset or is it just pulling the page as defined by the page size? I'm assuming that if I use a stored procedure with a datagrid, I won't be able to use the datagrid's paging anyway, and would have to create my own code in the stored procedure to return each page of...
5
2840
by: microsoft.private.windows.netserver.setup | last post by:
I have a very strange thing occurring in the program. I have a dataset retrieved from a stored procedure that just select * from a table. I then try to use the SQlCommandBuilder on the dataset, and fails. I try the same select statement directly and not using a stored procedure and use SQLCommandBuilder, the program works. This is a ASP.net page, and I am stumped. I would like to use the stored procedure rather than controlling it in...
1
1274
by: .Net Sports | last post by:
i have an aliased column in an sql statement that works fine when displaying its output in a datagrid, but when I transfer the sql statement into a stored procedure , the datagrid can't see it. I get an error "{"DataBinder.Eval: 'System.Data.DataRowView' does not contain a property with the name myaliasedcolumn." }
2
1769
by: Andrew Cooper | last post by:
Greetings, I'm creating a website using ASP.NET. In creating my DAL I've got a Table Adapter that I've set up to use an existing Stored Procedure from an SQL Server 2000 database. However, when I select the stored procedure I want to use the fields that are returned do not show up in the listbox for that stored procedure. If I continue and attempt to finish the Table Adapter I get the following error (even though the Adapter is...
3
2826
by: FrustratedNoob | last post by:
I've got a database that I've been working on for over a year and a half but I've just recently finished the back end to the point of feeling comfortable with starting on a front end. So while I've been able to pick up a great deal just stumbling through on my own with the several apress books I've gotten a hold of I've figured out a great deal and have some half decent forms for data entry but for the life of me I can't figure out how to get...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10211
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10045
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9994
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8872
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7409
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3562
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.