c# how do you return dataset from sqldatareader?

前端 未结 6 1263
[愿得一人]
[愿得一人] 2020-12-29 05:13

I have this in a public class:

SqlConnection myConnection = new SqlConnection(\"Data Source=hermes;database=qcvalues; Integrated Security=SSPI;\");
myConnect         


        
6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-29 05:50

    If your SelectCommand is stored procedure, the Fill method of the adapter will rise exception.

    In these cases you can use:

    DataTable dt = new DataTable();
    dt = sdr.GetSchemaTable();
    dt.Constraints.Clear();
    dt.BeginLoadData();
    dt.Load(sdr);
    //dt.EndLoadData(); // Enables constraints again
    

提交回复
热议问题