From:
<car...@te...> - 2003-02-22 23:43:41
|
Hello: > Reading is ok with reader, but how to write if i dont want to use adapter??? > Please wire example with smallest overheat... I need very fast > solution... I done it some way, but im not satisfied with it... Here is a sample for update a text blob field : using System; using System.IO; using System.Data; using System.Xml; using FirebirdSql.Data.Firebird; namespace Tests { public class ClobTest { public static void Main(string[] args) { string connectionString = "User=SYSDBA;Password=masterkey;" + @"Database=testdb.gdb;" + "DataSource=localhost;Port=3050;Dialect=3;Charset=NONE;" + "Role=;Connection lifetime=0;Pooling=true"; FbConnection myConnection = new FbConnection(connectionString); myConnection.Open(); FbTransaction myTransaction = myConnection.BeginTransaction(); FbCommand myCommand = new FbCommand(); myCommand.CommandText = "UPDATE TEST_TABLE_01 SET CLOB_FIELD = @CLOB_FIELD WHERE INT_FIELD = @INT_FIELD"; myCommand.Connection = myConnection; myCommand.Transaction = myTransaction; myCommand.Parameters.Add("@INT_FIELD", FbType.Integer, "INT_FIELD"); myCommand.Parameters.Add("@CLOB_FIELD", FbType.Text, "CLOB_FIELD"); myCommand.Parameters[0].Value = 1; myCommand.Parameters[1].Value = GetFileContents(@"GDS.CS"); myCommand.ExecuteNonQuery(); myCommand.Dispose(); myTransaction.Commit(); myConnection.Close(); } public static string GetFileContents(string fileName) { StreamReader reader = new StreamReader(new FileStream(fileName, FileMode.Open)); string contents = reader.ReadToEnd(); reader.Close(); return contents; } } } Best regards Carlos Guzmán Álvarez Vigo-Spain |