error 'there is already an open datareader associated with this command which must be closed first'

后端 未结 12 2279
情话喂你
情话喂你 2020-12-05 10:15

runtime error \'there is already an open datareader associated with this command which must be closed first\'

objCommand = new SqlCommand(\"SELECT field1, fi         


        
12条回答
  •  旧巷少年郎
    2020-12-05 10:55

    You can't perform an action on that connection while it's still working on reading the contents of a data reader - the error is pretty descriptive.

    Your alternatives are:

    1) Retrieve all your data first, either with a DataSet or use the reader to populate some other collection, then run them all at once after the initial select is done.

    2) Use a different connection for your insert statements.

提交回复
热议问题