From: Thomas <ja...@ma...> - 2003-11-19 22:50:30
|
When I insert this string: string t =3D "@123"; in my database,=20 only a "?" is appear in the database. When I retrive the value, I altso get a "?". Why are the "@" convertet to a "?"...... And why are everything after the "@" erased...... This problem only arise when I use Beta4 (v. 1.5.1410.16587). When I use beta2 (1.5.1356.23155) the whole string is insertet correct = in the database ("@123"). My code: ....... string t =3D "@123";=20 FB.insert("INSERT INTO TABLE1 (COL1) VALUES ( " + "'" + t + "'" + ")"); ...... ......... private string myConnectionString =3D "Database=3D" + "c:\\TEST.GDB" + = ";User=3D" + "SYSDBA" + ";Password=3D" + "masterkey" + ";Dialect=3D" + 1 = + ";Charset=3D" + "NONE" + ";Server=3D" + "localhost"; ............... .......... public bool insert(string myInsertQuery) { try { transaction =3D myConnection.BeginTransaction(); myCommandOne =3D new FbCommand(myInsertQuery, myConnection, = transaction);=20 myCommandOne.ExecuteNonQuery(); transaction.Commit(); myCommandOne.Dispose();=20 } catch(Exception ea) { ea =3D ea; throw new Exception(ea.Message); }//try/catch return true; } ..................... my table: CREATE TABLE TABLE1 ( COL1 VARCHAR( 55) ); I use: WinXP PRO SP1 .NET 1.1 Firebird-1.5.0.4027-RC7 as SuperServer Regards Thomas |
From: Pierre A. <pie...@op...> - 2003-11-20 07:30:59
|
Thomas wrote: > When I insert this string: string t = "@123"; in my database, > only a "?" is appear in the database. Hello Thomas, This is just an educated guess, but the Firebird ADO.NET provider uses @xxx to denote a parameter (FbParameter) in an FbCommand object. I guess you should get an exception telling you that 123 is not a valid parameter attached to the FbCommand object. Maybe Carlos will comment on this ? Kind regards. Pierre |
From:
<car...@te...> - 2003-11-20 09:27:54
|
Hello: > When I insert this string: string t = "@123"; in my database, > only a "?" is appear in the database. Thew @ is used inside the command text for denote a named parameter, named parameters detection is made using regular expressions: at this moment this the regex used: (@{1}\w+) in beta 2 it was: (@([a-zA-Z-$][a-zA-Z0-9_$]*)) But it's not handling ok the @ wen it appears inside '', if anybody knows how to modify it for handle ok this case i will be more than happy of modify it :) You can use parametrized querys for solve the problem. -- Best regards Carlos Guzmán Álvarez Vigo-Spain |
From: Thomas <ja...@ma...> - 2003-11-20 11:23:14
|
Hi Carlos Thanks for you'r reply. Can you give me an example on using parametrized querys? Regards Thomas ----- Original Message ----- From: "Carlos Guzmán Álvarez" <car...@te...> To: "Thomas" <ja...@ma...> Cc: "firebird" <fir...@li...> Sent: Thursday, November 20, 2003 10:26 AM Subject: Re: [Firebird-net-provider] Strange character problem with beta4? (v.1.5.1410.16587) > Hello: > > > When I insert this string: string t = "@123"; in my database, > > only a "?" is appear in the database. > > Thew @ is used inside the command text for denote a named parameter, > named parameters detection is made using regular expressions: at this > moment this the regex used: > > (@{1}\w+) > > in beta 2 it was: > > (@([a-zA-Z-$][a-zA-Z0-9_$]*)) > > > But it's not handling ok the @ wen it appears inside '', if anybody > knows how to modify it for handle ok this case i will be more than > happy of modify it :) > > > > You can use parametrized querys for solve the problem. > > > -- > Best regards > > Carlos Guzmán Álvarez > Vigo-Spain > > |
From:
<car...@te...> - 2003-11-20 11:43:37
|
Hello: > Hi Carlos > > Thanks for you'r reply. > > Can you give me an example on using parametrized querys? Of course :) FbConnection connection = new FbConnection(connectionString); FbTransaction transaction = connection.BeginTransaction(); FbCommand insert = new FbCommand("insert into table_name (field_name) values(@param_name)", connection, transaction); insert.Parameters.Add("@param_name", FbDbType.Char).Value="@123"; int affected = insert.ExecuteNonQuery(); transaction.Commit(); connection.Close(); -- Best regards Carlos Guzmán Álvarez Vigo-Spain |