We are trying to port our SQL 2000 to SQL 2008. But we ran into a problem; when the result set (rows or not) is returned using a query with UNION. Later in the code we try to add a new line and assign a field to it, but since UNION was used, when we try to assign a value to the field, it gives us the Multiple-step operation generated errors. Check each status value. Multiple-step operation generated errors. Check each status value. . We tried the following code on Windows XP and Windows 7 and got the same result. But when we change the connection string to return to our SQL 2000 mailbox, we no longer get this error.
The following example shows the problem we are having.
var c = new ADODB.Connection(); var cmd = new ADODB.Command(); var rs = new ADODB.Recordset(); object recordsAffected; c.Open("Provider=SQLOLEDB;Server=*****;Database=*****;User Id=*****;Password=*****;"); cmd.ActiveConnection = c; cmd.CommandType = ADODB.CommandTypeEnum.adCmdText; cmd.CommandText = "create table testing2008 (id int)"; cmd.Execute(out recordsAffected); try { cmd.CommandText = "select * from testing2008 union select * from testing2008"; rs.CursorLocation = ADODB.CursorLocationEnum.adUseClient; rs.Open(cmd, Type.Missing, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockBatchOptimistic, -1); rs.AddNew(); rs.Fields["id"].Value = 0;
source share