Hi,
I've been going at this for a few days and can't see the problem. Does
anyone see a problem with this code?
I have a call to a function that returns a dataset and when I assign
values to session variables, the values are the actual column names and
not the database value. I've tried using ordinal values and get the same
results.
--here's the code
--sql is defined here
Dim ds = New DataSet
ds = tools.GetDataSet(sql)
If ds.Tables(0).Columns("contact_id").ToString <> "" Then
Session("ContactID") = ds.Tables(0).Columns("contact_id").ToString
Session("CompanyID") = ds.Tables(0).Columns("company_id").ToString
GetContactData(Session("ContactID"), Session("CompanyID"))
ShowPanel(pnlStep1)
Else
lblMessage.Text = "User information not found"
End If
--My function looks like this
Public Shared Function GetDataSet(ByVal SQL As String) As DataSet
Dim cn As String
Dim adapter As SqlDataAdapter
Dim connection As SqlConnection
cn = ConfigurationSettings.AppSettings("CONN_STRING")
Try
connection = New SqlConnection(cn)
connection.Open()
adapter = New SqlDataAdapter(SQL, connection)
Dim myData As New DataSet
adapter.Fill(myData)
Return myData
Catch ex As Exception
Throw New Exception(ex.Message)
Finally
'clean up
adapter.Dispose()
connection.Close()
End Try
End Function
when I refer to ds.tables(0).Columns("contact_id").tostring or
ds.tables(0).columns(9).toString()...the value returned is "contact_id"
rather than 936. I've used this function before and it works fine. Does
anyone see a problem?
Thanks
Rob
*** Sent via Developersdex http://www.developersdex.com ***