Passing a Variable from a dataview

  • Thread starter Jim via DotNetMonster.com
  • Start date
J

Jim via DotNetMonster.com

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Passing a Variable 5
Variable from datareader 1
Connection 8
Timing out 9
Common Functions 3
Populate a dropdown list with a variable from a Querystring 2
Errors when Compiling a Class File 3
select textbox.text 3

Top