private void btnQuery_Click(object sender, EventArgs e) { string strSql = this.tboxSql.Text.Trim(); if (string.IsNullOrEmpty(strSql)) { return; } if (!CheckValid(strSql)) { FrmMain.PromptError(MyRes.Err_QueryInvalid); return; } Cursor.Current = System.Windows.Forms.Cursors.AppStarting; using ( var dbConn = new NativeDBHelper(m_connector.DBHost, m_connector.DBUser, m_connector.DBPassword, m_connector.CurDBName) ) { var dt = dbConn.Execute(strSql); ShowData(null, dt); } Cursor.Current = System.Windows.Forms.Cursors.Default; }
private Tuple <string, DataTable> LeftTree_QueryDataByNode(int nLimit = -1) { var curNode = this.treeObj.SelectedNode; var sDBName = LeftTree_GetDBNameFromPath(curNode.FullPath); Tuple <string, DataTable> retQuery = new Tuple <string, DataTable>(null, null); m_connector.CurDBName = sDBName; var sTabName = curNode.Text; using ( var dbConn = new NativeDBHelper(m_connector.DBHost, m_connector.DBUser, m_connector.DBPassword, sDBName) ) { StringBuilder sb = new StringBuilder(); if (nLimit < 0) { sb.AppendFormat("select * from {0}", sTabName); } else { sb.AppendFormat("select top {0} * from {1}", nLimit, sTabName); } var sSql = sb.ToString(); var dt = dbConn.Execute(sb.ToString()); retQuery = new Tuple <string, DataTable>(sSql, dt); return(retQuery); //return (nLimit < 0) ? dbConn.GetDataFromTable(sTabName) : dbConn.GetDataFromTableTopN(sTabName, 100); } }