From: Mike S. <mi...@mi...> - 2003-04-16 10:03:37
|
Hi Carlos The way you're currently splitting commands (both in batch commands and in FbScript.cs) doesn't work properly. If there is a string containing a semi-colon, it will break. Here's some sample code to illustrate: const string connectionString = "User=SYSDBA;" + "Password=masterkey;" + "DataSource=localhost;" + "Port=3050;" + "Dialect=1;" + "Charset=NONE;" + "Role=;" + "Connection lifetime=15;" + "Pooling=true;" + "Packet Size=8192;" + "Database="; try { string fileName = Path.GetTempPath() + "Temp.gdb" ; File.Delete( fileName ) ; Console.WriteLine( "Creating temporary DB '{0}'", fileName ) ; FbConnection.CreateDatabase( "localhost", 3050, fileName, "SYSDBA", "masterkey", 1 ) ; using ( FbConnection connection = new FbConnection( connectionString + fileName ) ) { connection.Open(); using( FbTransaction transaction = connection.BeginTransaction() ) { using( FbCommand command = new FbCommand( "CREATE TABLE TESTTABLE(STRINGFIELD VARCHAR(50))", connection, transaction ) ) { command.ExecuteNonQuery() ; transaction.CommitRetaining() ; Console.WriteLine( "About to try to insert a string containing a semi-colon - it will fail" ) ; command.CommandText = "INSERT INTO TESTTABLE VALUES ( 'This is a semi-colon ;' );" + "INSERT INTO TESTTABLE VALUES ( 'This is not a semi-colon !' );" ; using ( FbDataReader reader = command.ExecuteReader() ) { while ( reader.NextResult() ) { } } } transaction.Commit(); } } } catch ( Exception E ) { Console.WriteLine( "{0}: {1}", E.GetType().Name, E.Message ) ; } Console.Write( "Hit enter" ) ; Console.ReadLine() ; Cheers, Mike. |