public override void Execute() { ConnectionState prevState = mConn.State; if (prevState != ConnectionState.Open) { mConn.Open(); } if (mDA.SelectCommand == null) { mDA.SelectCommand = new SqlCommand(SQL, mConn.AdoCon); } mDS = new DataSet(); mState = RSState.Executing; //mDA.Fill(mDS, "Result"); mDA.Fill(mDS, "Result"); Fields = mDS.Tables["Result"].Columns.Cast <DataColumn>().Select(x => x.ColumnName).ToList(); //await Task.Run(()=> mDA.Fill(mDS, "Result")); MoveFirst(); mState = RSState.Open; if (prevState != ConnectionState.Open) { mConn.Close(); } }
public override void Execute() { ConnectionState prevState = mConn.State; if (prevState != ConnectionState.Open) { mConn.Open(); } Cmd = new SqlCommand(SQL, mConn.AdoCon); mState = RSState.Executing; try { mDR = Cmd.ExecuteReader(); Fields = mDR.GetSchemaTable().Rows.OfType <DataRow>().Select(r => r["ColumnName"].ToString()).ToList(); //EOF = ! mDR.Read(); dT = new DataTable(); dT.Load(mDR); Result = dT.Rows.OfType <DataRow>().ToList(); EOF = RecordCount == 0; Index = 0; } catch (Exception ex) { Console.WriteLine(ex.Message); } mState = RSState.Open; if (prevState != ConnectionState.Open) { mConn.Close(); } Index = 0; }
public override void Execute() { ConnectionState prevState = mConn.State; if (prevState != ConnectionState.Open) { mConn.Open(); } Cmd = new SqlCommand(SQL, mConn.AdoCon); mState = RSState.Executing; try { mDR = Cmd.ExecuteReader(); //EOF = ! mDR.Read(); var _dt = new DataTable(); _dt.Load(mDR); Result = _dt.Rows.OfType <DataRow>().ToList(); EOF = Result.Count() == 0; Index = 0; } catch (Exception ex) { Console.WriteLine(ex.Message); } mState = RSState.Open; if (prevState != ConnectionState.Open) { mConn.Close(); } Index = 0; }
public SP(cAccesoDatosNet pConn, string pSPName = "") { Cmd = new SqlCommand(); ControlParameters = new List <ControlParameter>(); OutputParameters = new List <SqlParameter>(); //ObjectParameters = new List<ObjectParameter>(); SPName = pSPName; Conn = pConn; Connection = Conn.AdoCon; CommandType = System.Data.CommandType.StoredProcedure; CommandText = pSPName; ConnectionState prevState = mConn.State; if (prevState != ConnectionState.Open) { mConn.Open(); } SqlCommandBuilder.DeriveParameters(Cmd); if (MsgOut) { Parameters["@msg"].Value = ""; } Cmd.CommandTimeout = 300; if (prevState != ConnectionState.Open) { mConn.Close(); } }
public override void Execute() { ConnectionState prevState = mConn.State; if (prevState != ConnectionState.Open) { mConn.Open(); } if (mDA.SelectCommand == null) { mDA.SelectCommand = new SqlCommand(SQL, mConn.AdoCon); } mDS = new DataSet(); mState = RSState.Executing; //mDA.Fill(mDS, "Result"); mDA.Fill(mDS, "Result"); //await Task.Run(()=> mDA.Fill(mDS, "Result")); MoveFirst(); mState = RSState.Open; if (prevState != ConnectionState.Open) { mConn.Close(); } }