Friday, March 16, 2012

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] = @dotnet.itags.org.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 = "@dotnet.itags.org.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.webservertalk.comI figured it out. I was declaring the variable in the function.
Message posted via http://www.webservertalk.com

0 comments:

Post a Comment