private static void CloseDataReader(HanaDataReader dataReader) { if (dataReader != null) { dataReader.Close(); dataReader.Dispose(); } }
private DataTable GetReportData() { DataGridView gr = new DataGridView(); HanaConnection conn = new HanaConnection(string.Format("Server={0};UserID={1};Password={2}", ConfigurationManager.AppSettings["SAPServer"], ConfigurationManager.AppSettings["SAPUsername"], ConfigurationManager.AppSettings["SAPPassword"])); conn.Open(); HanaCommand selectCmd = new HanaCommand(string.Format("SELECT \"QUERY\" AS \"SqlQuery\" FROM {1}.\"@PRINTDOCUMENT\" WHERE \"Code\" LIKE '{0}'", this.oid, ConfigurationManager.AppSettings["SAPDatabase"]), conn); HanaDataReader dr = selectCmd.ExecuteReader(); gr.DataSource = dr; DataTable dt = new DataTable(); dt.Load(dr); dr.Close(); conn.Close(); if (dt == null || dt.Rows.Count == 0) { return(null); } var cmdText = System.Text.ASCIIEncoding.ASCII.GetString((byte[])dt.Rows[0]["SqlQuery"]); if (string.IsNullOrEmpty(cmdText)) { return(null); } return(Utility.hanaConnection(cmdText)); //var conn1 = DBConnection.conn; //try //{ // var obj = Utility.hanaConnection(string.Format("SELECT \"QUERY\" AS \"SqlQuery\" FROM \"@PRINTDOCUMENT\" WHERE \"Code\" LIKE '{0}'", this.oid)); // if (obj == null || obj.Rows.Count == 0) return null; // var cmdText = System.Text.ASCIIEncoding.ASCII.GetString((byte[])obj.Rows[0]["SqlQuery"]); // if (string.IsNullOrEmpty(cmdText)) return null; // return // Utility.GetObjects(cmdText, conn1); //} //catch (Exception) //{ // return null; //} }