From: Christopher W. <chr...@ad...> - 2003-05-29 17:25:57
|
Hi- FYI to anyone interested: It doesn't seem that efficient, but I solved the problem by iterating over the byte[] contents in a loop and appending the result of (char)byte[i] to a StringBuilder instance. I set the FBType of the parameter to Char and write the string to the database without a problem. I also write the actual length of the data to another column because it represents a serialized object and must be deserialized into an instance. The column that is defined as char(x) character set octets does allow the delete statement that uses it in the where clause to work properly. When I get the results of the select, I need to transform the string representing the binary data into the datatable column format of Base64Binary. That rules out dataAdapter.Fill( dateSet ). Instead I used the following code to load the data from the database table into the dataset: FbDataReader reader = m_daSinks.SelectCommand.ExecuteReader(); byte[] buff1, buff2; while( reader.Read() ) { buff1 = ASCIIEncoding.Default.GetBytes( reader.GetString( 0 ) ); // Binary data is in first column buff2 = new byte[ reader.GetInt16( 1 )]; // Actual Length of the binary data Array.Copy( buff1, 0, buff2, 0, buff2.Length ); object[] vals = new Object[]{ reader.GetInt64(2), buff2, DateTime.Now, EventName }; ds.Tables["tb_sinks"].LoadDataRow( vals, true ); } reader.Close(); Any suggestions for improving this approach would be greatly appreciated. Regards, Chris Whelan |