MS SQL Stored Procedure with multiple recordsets

Hi!

I’m launching a Stored Procedure that has multiple recordsets as output, with this code I can read only the first recordset

Dim db As New MSSQLServerDatabase

db.Host =Icam_Opera_Log.host // or just the IP if using the default instance
db.DatabaseName = Icam_Opera_Log.dbnm
db.UserName = Icam_Opera_Log.user  // or "Domain\UserID for trusted domain accounts
db.Password = Icam_Opera_Log.pass

TxtLog.Text=""

If db.Connect Then
  dim stringa_sql as string
  Dim ps As MSSQLServerPreparedStatement
  Dim rs As RecordSet 
  stringa_sql="ICAM_RunImport_TEST_XML"
  
  ps = db.Prepare(stringa_sql)
  rs = ps.SQLSelect
  
  ''break
  if rs <> Nil Then
    While Not rs.EOF
      try
        TxtLog.text=TxtLog.text+rs.IdxField(1).StringValue+" - "+rs.IdxField(2).StringValue+chr(13)
      catch
        TxtLog.text=TxtLog.text+rs.IdxField(1).StringValue+chr(13)
      end try
      rs.MoveNext
    Wend
    rs.Close
  end if
  db.Close
Else
  MsgBox("Connection error:" + db.ErrorMessage)
End If

how can I read all the recordsets?

some recordsets have 1 field, other 2 or more.

You may need to switch to MBS Xojo SQL Plugin to get multiple record sets.

See also
Multiple recordsets with Microsoft SQL Server