I don' usually put code on forums, but i can't seem to get a recordset with this code, while the stored procedure should return one, i have tried to debug but just am stuck, anyone with an idea. There are no records affected, after cm.executereader. So the activelookup remains empty, anyone.
Willem
Protected
Overrides Sub DataPortal_Fetch(ByVal Criteria As Object) Dim s As String Dim crit As CustomCriteria = DirectCast(Criteria, CustomCriteria) Using cn As New System.Data.SqlClient.SqlConnection(ActiveObjects.My.Settings.CDOLVSConnection)cn.Open()
Dim cm As IDbCommand = Nothingcm = cn.CreateCommand
cm.CommandType = CommandType.StoredProcedure
cm.CommandText =
"usp_getKolomNamen"s =
"tbl" + crit.TableName Dim param As New SqlClient.SqlParameterparam.ParameterName =
"@TabelNaam"param.Value = s
MsgBox(crit.TableName)
param.Direction = ParameterDirection.Input
cm.Parameters.Add(param)
Using cm Using dr As New SafeDataReader(cm.ExecuteReader)IsReadOnly =
False Dim i As Integeri = dr.RecordsAffected
Dim k As Integerk = 0
Try While dr.Read()MsgBox(dr.GetValue(4 + i).ToString)
k = i - 1
Me.Add(New NameValuePair(k.ToString, dr.GetValue(4 + i).ToString))i = i + 1
End While Finally End TryIsReadOnly =
True End Using End Using End Using End SubI guess your sproc is a SELECT... statement? You may want to check out MSDN - says IDataReader.RecordsAffected doesn't get set until you read everything and close the IDataReader.
Regardless, whenver I expect to get some rows back and I don't, I fire up the profiler and check out what's really going on. Copy what the profiler says when you execute your sproc, and paste into a new query window and run it from there. Usually I have a simple typo.
Copyright (c) Marimer LLC