Your function is returning an OleDbDataReader, not a string.
You'd have to use it like this:
Dim r As OleDbDataReader = CreateSlxID("account", 1) If r.Read() Then MessageBox.Show("New ACCOUNTID: " & r(0).ToString()) End If
If you want it to return a string you'd change it to this (changes in bold):
Function CreateSlxID(ByVal Table As String) As String Dim SlxConn2 As New OleDb.OleDbConnection Dim cmd As New OleDb.OleDbCommand("slx_dbids('" & Table & " ', 1)", SlxConn2) SlxConn2.ConnectionString = "MYSLXCONNSTRING" SlxConn2.Open() CreateSlxID = cmd.ExecuteScalar() cmd.Dispose() SlxConn2.Dispose() End Function
Of course, if you're returning a simple string then you can't return multiple, only a single ID, so no need for the second param for the function. Then you could use it like this:
.Fields("C_WebQQ_ActiveId").Value = CreateSlxID("C_WEBQQ_Active")
Make sense?
-Ryan |