473,320 Members | 1,953 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Passing a Dataset from a function in a class

Hi, I have a class called Jobs. In that class is the function below..

Public Function GetJobTitle(ByVal Job_Title_ID As Integer, ByVal Company_ID
As Integer) As DataSet
' Setup the Stored Procedure
Dim SqlCommand As New SqlCommand
Dim SqlConnection As New SqlConnection(DataLayer.ConnectionString)
Try
SqlCommand.CommandText = "dbo.DeleteJobTitle"
SqlCommand.CommandType = System.Data.CommandType.StoredProcedure
SqlCommand.Connection = SqlConnection
' Load the Parameters
SqlCommand.Parameters.Add(New
System.Data.SqlClient.SqlParameter("RETURN_VALUE",
System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue,
False, CType(0, Byte), CType(0, Byte), "",
System.Data.DataRowVersion.Current, Nothing))
SqlCommand.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Job_Title_ID" ,
System.Data.SqlDbType.Int, 4)).Value = Job_Title_ID
SqlCommand.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Company_ID", System.Data.SqlDbType.Int,
4)).Value = Company_ID
' Fire the Procedure
SqlConnection.Open()
' Create a dataset
Dim da As SqlDataAdapter = New SqlDataAdapter
da.SelectCommand = SqlCommand
Dim ds As New DataSet
da.Fill(ds, "JobTitle")
Return ds
Catch ex As Exception
Throw New Exception(ex.ToString)
Finally
SqlConnection.Close()
End Try
End Function

I now have a web form called Default.aspx

How can I poplulate a Datagrid or Select box from the above function?

Datagrid1.Datasource = jobs.GetJobTitle(1,1) ???

Please help

Thanks Daren
Nov 19 '05 #1
1 1217
"Daren Hawes" <ne********@webdesignmagic.com.au> wrote in
news:uO**************@TK2MSFTNGP14.phx.gbl:

I now have a web form called Default.aspx

How can I poplulate a Datagrid or Select box from the above function?

Datagrid1.Datasource = jobs.GetJobTitle(1,1) ???


Yes exactly - but just remember to call Datagrid1.databind.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 19 '05 #2

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

Similar topics

3
by: Simon Harvey | last post by:
Hi, In my application I get lots of different sorts of information from databases. As such, a lot of information is stored in DataSets and DataTable objects. Up until now, I have been passing...
19
by: Jaime Stuardo | last post by:
Hi all.. I have created a business logic component that is used from my ASP.NET webform. It works, but connection string to the database is hard coded, as in this method : public DataSet...
4
by: Gr8North | last post by:
I'm relatively new to .Net, and would appreciate a little assistance. I have multiple datasets attached to individual grids on individual tabs on a form. I would like to have a series of...
0
by: Eric Sabine | last post by:
OK, I'm trying to further my understanding of threading. The code below I wrote as kind of a primer to myself and maybe a template that I could use in the future. What I tried to do was pass data...
1
by: Wes Hutton via .NET 247 | last post by:
I am trying to pass a data object (set or row) into a functionbyref, and have the same issue either way. In the maincontroller function, I have no issues accessing any parts of mydataset. If I...
5
by: Darious Snell | last post by:
I am using windows forms and vb.net. My problem is a little complex so please bear with me. I have written an application that references a .com based API linked to an external client...
0
by: Iain McIntosh | last post by:
Hello if anyone can help me with this I will be very grateful. I have a working version of this program as a windows application, when I try to port it over to c# ASP.NET I can't make it work. ...
2
by: Carl Heller | last post by:
Working in VS2003, .Net 1.1 I'm working on a project where I compare data between two databases. This is a lengthy process, and very data intensive, so I decided to create a class, and thread...
4
by: John Sheppard | last post by:
Hello there I was wondering if anyone could help me, I am trying to pass a typed dataset to a dialoged child form by reference. I have binding sources sitting on the child form. So to refresh...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.