bool parseSQLNoneQuery(string sSQL, SQLNoneQuery sql) { string sMsg; if (string.IsNullOrEmpty(sql.TableName) && objRet != null) { sql.TableName = objRet.TableName; } sql.SetConnection(dbConn); bool b = sql.parseSQLNoneQuery(this, sSQL, out sMsg); txtInfo.Text = sMsg; return(b); }
private void showSQL() { EnumEditState st = editState; editState = EnumEditState.Loading; // loadFromCache(); // objRet.SetConnection(dbConn); // if (ds != null && ds.Tables.Count > 0) { for (int j = 0; j < ds.Tables[0].Rows.Count; j++) { ds.Tables[0].Rows[j][1] = false; ds.Tables[0].Rows[j][2] = string.Empty; } // bool b2 = bSQLChanged; bSQLChanged = true; txtWhere.Text = objRet.Filter; txtSQL.Text = objRet.SQL; if (checkSyntax()) { objRet.SetFilter(adjustFilter(objRet.Filter)); txtWhere.Text = objRet.Filter; txtSQL.Text = objRet.SQL; txtWhere.SelectionStart = txtWhere.Text.Length; txtSQL.SelectionStart = txtSQL.Text.Length; btQueryBuilder.Enabled = (objRet.CommandType != enmNonQueryType.Insert); bSQLChanged = b2; txtSQL.ForeColor = Color.Black; } } editState = st; }
private bool checkSyntax() { if (bSQLChanged) { QueryParser._UseLowerCase = dbConn.LowerCaseSqlKeywords; SQLNoneQuery sql = new SQLNoneQuery(); sql.SetConnection(dbConn); ParameterList ps = objRet.ParseParams(); if (ps != null) { sql.SetParameters(ps); } if (parseSQLNoneQuery(txtSQL.Text, sql)) { string tblName = objRet.TableName; objRet = sql; if (string.IsNullOrEmpty(objRet.TableName)) { objRet.TableName = tblName; } enmNonQueryType qt = enmNonQueryType.Insert; if (cbxType.SelectedIndex >= 0) { qt = (enmNonQueryType)(cbxType.SelectedIndex); } if (qt != objRet.CommandType) { cbxType.SelectedIndex = (int)qt; } for (int i = 0; i < lstTable.Items.Count; i++) { if (string.Compare(objRet.TableName, lstTable.Items[i].ToString(), StringComparison.OrdinalIgnoreCase) == 0) { if (i != lstTable.SelectedIndex) { lstTable.SelectedIndex = i; EnumEditState st = editState; editState = EnumEditState.Ready; lstTable_SelectedIndexChanged(this, EventArgs.Empty); editState = st; } break; } } setFieldTypes(); saveTocCache(); if (ds != null) { for (int j = 0; j < ds.Tables[0].Rows.Count; j++) { ds.Tables[0].Rows[j][1] = false; ds.Tables[0].Rows[j][2] = ""; } for (int i = 0; i < objRet.FieldCount; i++) { EPField f = objRet.GetField(i); if (f != null) { for (int j = 0; j < ds.Tables[0].Rows.Count; j++) { string fn = ds.Tables[0].Rows[j][0].ToString(); if (string.Compare(f.Name, fn, StringComparison.OrdinalIgnoreCase) == 0) { ds.Tables[0].Rows[j][1] = true; ds.Tables[0].Rows[j][2] = f.FieldText; break; } } } } } return(true); } else { txtSQL.ForeColor = System.Drawing.Color.Red; return(false); } } return(true); }