日期:2014-05-18  浏览次数:20364 次

可不可以把一个DataTable对象直接存入到sql server2000字段里?
可不可以把一个DataTable对象直接存入到sql   server2000字段里?
如果可以,怎么设置、存入和读取?

------解决方案--------------------
[SerializableAttribute]
public class DataTable : MarshalByValueComponent, IListSource, ISupportInitializeNotification, ISupportInitialize,
ISerializable, IXmlSerializable


使用序列化,不过感觉你的要求很奇怪也。
------解决方案--------------------
不懂可以搜索:.net 序列化
------解决方案--------------------

System.Runtime.Serialization.Formatters.Binary.BinaryFormatter format = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
System.IO.MemoryStream stream = new System.IO.MemoryStream();
DataTable dt = new DataTable();
format.Serialize(stream,dt);
byte[] buffers = stream.GetBuffer();
然后存入binay 字段