Results 1 to 7 of 7

Thread: Using a function in a dataset before returning it

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2005
    Posts
    259

    Using a function in a dataset before returning it

    I have a field in a dataset that I would like to run through a function and then add the result to the dataset before returning it to the sub.

    Right now I am getting the dataset, putting the ZipCodes into an array and then getting my distance calc after the fact. This works ok but it would be far better to have included with the original dataset.

    This is what I am doing now.
    VB Code:
    1. Dim getZip As String = txtZip.Text
    2.         Dim getRad As Integer = RadioButtonList1.SelectedValue
    3.         Dim myDS As DataSet = GetUE_ZipRadius(getZip, getRad)
    4.         DataList1.DataSource = myDS
    5.         DataList1.DataBind()
    6.  
    7.         With myDS.Tables("ZipCodes")
    8.             Dim zipCodesA(.Rows.Count - 1) As String
    9.             For i As Integer = 0 To .Rows.Count - 1
    10.                 zipCodesA(i) = CStr(DirectCast(.Rows(i).Item("ueZip"), Integer))
    11.                 LookUpZipCode(getZip, zipCodesA(i))
    12.                 ListBox1.Items.Add(Format(CalcDistance(), "F").ToString)
    13.             Next
    14.         End With
    15.  
    16.         myDS.Dispose()

    Is it possible to the (Format(CalcDistance(), "F").ToString) before hand and have the distances added as a column to the dataset?

    Oh yea the dataset code looks like this
    VB Code:
    1. Dim LowLatitude As Double = iStartLat - LatRange
    2.         Dim HighLatitude As Double = iStartLat + LatRange
    3.         Dim LowLongitude As Double = iStartLon - LonRange
    4.         Dim HighLongitude As Double = iStartLon + LonRange
    5.  
    6.         Dim strSelect2 As String = _
    7.             "Select ueStore, ueAddress, ueCity, ueState, " & _
    8.             "ueZip, uePhone From queUncEdsZCodes " & _
    9.             "Where Latitude <=" & HighLatitude & _
    10.             "And Latitude >=" & LowLatitude & _
    11.             "And Longitude <=" & HighLongitude & _
    12.             "And Longitude >=" & LowLongitude
    13.  
    14.         Dim Cmd2 As New OleDbDataAdapter(strSelect2, conn)
    15.         Dim ds As New DataSet
    16.         Cmd2.Fill(ds, "ZipCodes")
    17.  
    18.         Return ds
    Last edited by FastEddie; Mar 28th, 2006 at 08:09 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width