我再c#中写程序用SQLServer2000,需要把一个TXT文本写入到数据库中,写详细点 最后注释下

第1个回答  2011-12-06
读取txt:
private void Open()
{

openFileDialog1.Filter = "(*.txt)|*.txt";
openFileDialog1.FileName = "20110901.txt";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
recordPathMobile = openFileDialog1.FileName;
FileStream stream = new FileStream(recordPathMobile, FileMode.OpenOrCreate, FileAccess.Read);
....................
}
保存:
private void Store()
{
if (recordPathMobile == null)
{
Common.MsgInfo("请先选择需要导入的文本……");
return;
}

byte[] byDataBuf = null;
FileStream stream = new FileStream(recordPathMobile, FileMode.OpenOrCreate, FileAccess.Read);
byDataBuf = File.ReadAllBytes(recordPathMobile);

}
第2个回答  2011-12-06
1、读取txt文本到字符串
2、将字符串写入数据库追问

能在详细点吗 写代码 谢谢

本回答被网友采纳
第3个回答  2011-12-06
数据库中能直接存放txt文件的
相似回答
大家正在搜