473,396 Members | 1,767 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,396 software developers and data experts.

Passing a Variable from a dataview

Hi,

I'm assigning the value of a variable(MotivateNumber) in a Dataview object
of a dataset. I get the correct value in the dataset. When I try to run the
function to get the value I get a 0. How can I pass the variable to outside
the function. It's declared outside:

Dim MotivateNumber as Integer

Sub Page_Load(sender As Object, e As EventArgs)
GetPart(42)
Page.Databind()
End Sub
Function GetPart(ByVal lessonID As Integer) As DataSet
...connection info
Dim queryString As String = "SELECT ([tblPage].[Part]), [tblPage].
[PageNumber] FROM [tblPage] WHERE ([tblPage].[LessonID] = @LessonID) order
by [tblPage].[PageNumber]"

Dim dbCommand As New SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

Dim dbParam_lessonID As New SqlParameter
dbParam_lessonID.ParameterName = "@LessonID"
dbParam_lessonID.Value = lessonID
dbParam_lessonID.DbType = DbType.Int32
dbCommand.Parameters.Add(dbParam_lessonID)

Dim dataAdapter As New SqlDataAdapter(queryString, dbConnection)
dataAdapter.SelectCommand = dbCommand

Dim dataset as New DataSet()
dataAdapter.Fill(dataSet, "tblPages")
Dim tblPages as DataTable = dataset.Tables("tblPages")

Dim dvMotivate as New DataView(tblPages)
dvMotivate.RowFilter="Part='Motivate'"
Dim MotivateNumber=dvmotivate(0)("PageNumber")

Return dataSet
End Function

--
Message posted via http://www.dotnetmonster.com
Nov 19 '05 #1
1 1228
I figured it out. I was declaring the variable in the function.

--
Message posted via http://www.dotnetmonster.com
Nov 19 '05 #2

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

Similar topics

3
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
7
by: Harolds | last post by:
The code below worked in VS 2003 & dotnet framework 1.1 but now in VS 2005 the pmID is evaluated to "" instead of what the value is set to: .... xmlItems.Document = pmXML // Add the pmID...
2
by: Tom Lee | last post by:
Hi all, I have the following problem and I cannot solve it. If anyone can help me solve this problem. I use the following code <%#DataBinder.Eval(Container.DataItem, "Property")%> to display...
3
by: John Wildes | last post by:
Hello all I am trying to pass a variable to a DataView so that I can filter the rows displayed in my datagrid. Here's the code I am trying to get to work Private Sub...
1
by: Larry Bird | last post by:
I've successfully created a dataview that I want to passing to another subroutine. See Example below: Creation of dataview: For Each CriteriaDetailRow In...
2
by: hcs | last post by:
Hello, i have a form which has a datagrid and another which displays some information. what i would like is to be able to double click a row on the datagrid on form B and then display the select...
12
by: Andrew Bullock | last post by:
Hi, I have two classes, A and B, B takes an A as an argument in its constructor: A a1 = new A(); B b = new B(a1);
3
by: DaTurk | last post by:
If I call this method, and pass it a byte by ref, and initialize another byte array, set the original equal to it, and then null the reference, why is the original byte array not null as well? I...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...
0
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...
0
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,...

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.