Thanks for the response, I have been away for a while. Bug fixed, here is fixed procedure.
public string ParseNamedParameters(string sql) { // Clear old parameters. this.namedParameters.Clear(); // We do not need to parse if there are no parameters. if (sql.IndexOf('@') == -1) { return sql; } int index; int end = sql.Length - 1; StringBuilder resultBuilder = new StringBuilder(sql.Length); for (int i = 0, j = sql.Length; i < j; i++) { switch (sql[i]) { // Read a named parameter. case '@': for (index = i + 1; index < j && (Char.IsLetterOrDigit(sql[index]) || sql[index] == '_' || sql[index] == '$'); index++); resultBuilder.Append('?'); this.namedParameters.Add(sql.Substring(i, index - i)); i = index - 1; continue; // Read quoted text. case '\'': case '"': for (index = i + 1; index < j && sql[index] != sql[i]; index++); if(index >= j) { resultBuilder.Append(sql.Substring(i)); } else { resultBuilder.Append(sql.Substring(i, index + 1 - i)); } i = index; continue; // Read a single line comment. case '-': if ((i < end) && (sql[i + 1] == '-')) { for (index = i + 1; index < j && (sql[index] != '\r' && sql[index] != '\n'); index++); resultBuilder.Append(sql.Substring(i, index - i)); i = index - 1; continue; } resultBuilder.Append('-'); continue; // Read a block comment. case '/': if ((i < end) && (sql[i + 1] == '*')) { while (i < j) { resultBuilder.Append(sql[i]); if (sql[i] == '*' && i < end && sql[i + 1] == '/') { break; } i++; } continue; } resultBuilder.Append('/'); continue; // Read content. default: resultBuilder.Append(sql[i]); continue; } } return resultBuilder.ToString(); } On Sat, Mar 21, 2009 at 1:13 PM, Jiri Cincura <disk...@cincura.net> wrote: > On Tue, Mar 3, 2009 at 23:43, Gareth <gareth.gosl...@gmail.com> wrote: >> This method runs faster than the current one, it does not strip >> anything except "@PARAMETER" text to "?" and there are not alot of >> booleans. >> >> If you think this is ok, I will add a patch to DNET-176. > > > Hi, sorry for taking long time to respond. > > It's not correct. Try to parse i.e. "select '@bar\"". You'll end up > with exception. > > -- > Jiri {x2} Cincura (CTO x2develop.com) > http://blog.vyvojar.cz/jirka/ | http://www.ID3renamer.com -- Gareth ------------------------------------------------------------------------------ This SF.net email is sponsored by: High Quality Requirements in a Collaborative Environment. Download a free trial of Rational Requirements Composer Now! http://p.sf.net/sfu/www-ibm-com _______________________________________________ Firebird-net-provider mailing list Firebird-net-provider@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/firebird-net-provider