/// <summary> /// /// </summary> /// <param name="queryString"></param> /// <returns></returns> public List <double> QueryDataReturnListDouble(string queryString) { if (con == null || con.State != 1) { this.OpenConnection(); } if (con.State != 1) { return(null); } //open recordset rs = new ADODB.Recordset(); rs.Open(queryString, con); //get data object[,] dataRows = (object[, ])rs.GetRows(); List <double> ts = new List <double>(); for (int i = 0; i < dataRows.GetLength(1); i++) { object[] p = Enumerable.Range(0, dataRows.GetLength(0)).Select(x => dataRows[x, i]).ToArray(); ts.Add((double)p[0]); } //close recordset rs.Close(); rs = null; //return data return(ts); }
public object[] db_access(string strSQL) { ADODB.Connection objCon; ADODB.Recordset objRec; object[,] dataRows; object[] dataSuite; string strCon; objCon = new ADODB.Connection(); objRec = new ADODB.Recordset(); //establish the connection string and open the database connection strCon = "driver={MySQL ODBC 5.1 Driver};server=107.22.232.228;uid=qa_people;pwd=thehandcontrols;" + "database=functional_test_data;option=3"; objCon.Open(strCon); //execute the SQL and return the recrodset of results objRec = objCon.Execute(strSQL, out missing, 0); //populate a two dinmensional object array with the results dataRows = objRec.GetRows(); //get a onedimensional array that can be placed into the Test Suite dropdown dataSuite = thinArray(dataRows); //close the recordset objRec.Close(); //close the database connection objCon.Close(); return(dataSuite); }
/// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <param name="queryString"></param> /// <returns></returns> public List <T> QueryDataReturnListObject <T>(string queryString) where T : new() { if (con == null || con.State != 1) { this.OpenConnection(); } if (con.State != 1) { return(null); } //Get properties of T Type itemType = typeof(T); var properties = itemType.GetProperties(BindingFlags.Public | BindingFlags.Instance); //open recordset rs = new ADODB.Recordset(); rs.Open(queryString, con); //get data object[,] dataRows = (object[, ])rs.GetRows(); List <T> ts = new List <T>(); for (int i = 0; i < dataRows.GetLength(1); i++) { object[] p = Enumerable.Range(0, dataRows.GetLength(0)).Select(x => dataRows[x, i]).ToArray(); T t = new T(); for (int k = 0; k < properties.Length; k++) { properties[k].SetValue(t, Convert.ChangeType(p[k], properties[k].PropertyType)); } ts.Add(t); } //close recordset rs.Close(); rs = null; //return data return(ts); }
public object[] db_access(string strSQL) { ADODB.Connection objCon; ADODB.Recordset objRec; object[,] dataRows; object[] dataSuite; string strCon; objCon = new ADODB.Connection(); objRec = new ADODB.Recordset(); //establish the connection string and open the database connection strCon = "driver={MySQL ODBC 5.1 Driver};server=107.22.232.228;uid=qa_people;pwd=thehandcontrols;" + "database=functional_test_data;option=3"; objCon.Open(strCon); //execute the SQL and return the recrodset of results objRec = objCon.Execute(strSQL, out missing, 0); //populate a two dinmensional object array with the results dataRows = objRec.GetRows(); //get a onedimensional array that can be placed into the Test Suite dropdown dataSuite = thinArray(dataRows); //close the recordset objRec.Close(); //close the database connection objCon.Close(); return dataSuite; }
private object[] db_access(string strSQL, ref int fndExcep) { ADODB.Connection objCon; ADODB.Recordset objRec; object[,] dataRows; object[] dataSuite; string strCon; string tmpString; dataSuite = null; objCon = new ADODB.Connection(); objRec = new ADODB.Recordset(); try { //establish the connection string and open the database connection strCon = "driver={MySQL ODBC 5.1 Driver};server=107.22.232.228;uid=qa_people;pwd=thehandcontrols;" + "database=functional_test_data;option=3"; objCon.Open(strCon); //execute the SQL and return the recrodset of results objRec = objCon.Execute(strSQL, out missing, 0); //populate a two dinmensional object array with the results dataRows = objRec.GetRows(); //get a one dimensional array that can be placed into the Test Suite dropdown dataSuite = thinArray(dataRows); //close the recordset objRec.Close(); //close the database connection objCon.Close(); } catch (Exception e) { tmpString = e.Message; //set the variable to ternibate the script fndExcep = -1; } return dataSuite; }