using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
using System.IO; namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
string conn = "Data Source=(local); Database=modelsearch3;Integrated Security=SSPI;";
SqlConnection objcon = new SqlConnection(conn);
SqlDataAdapter adapter;
adapter = new SqlDataAdapter("select * from model", objcon);
SqlCommandBuilder sqlBuilder = new SqlCommandBuilder(adapter);
objcon.Open();
DataTable dt = new DataTable("model");
adapter.Fill(dt);
for (int i = ; i < ; i++)
{
DataRow row = dt.Rows[i];
string f = row.ItemArray[].ToString();
string s = row.ItemArray[].ToString();
string t = row.ItemArray[].ToString();
//StreamWriter fw = File.AppendText("C:\\frontString.txt");
//fw.Write(f + "\r\n");
//StreamWriter sw = File.AppendText("C:\\sideString.txt");
//sw.Write(s + "\r\n");
//StreamWriter tw = File.AppendText("C:\\topString.txt");
//tw.Write(t + "\r\n");
StreamWriter zw = File.AppendText("C:\\modelString.txt");
zw.Write(f + s + t + "\r\n");
//fw.Close();
//sw.Close();
//tw.Close();
zw.Close();
}
}
}
}

参考:

http://zhidao.baidu.com/question/318486288.html

http://www.cnblogs.com/aidd2008/archive/2008/12/05/1348695.html

C#读取文本

            int file_count = ;
StreamReader front_file_reader = new StreamReader("C:\\front_coordinate_add.txt");
StreamReader side_file_reader = new StreamReader("C:\\side_coordinate_add.txt");
StreamReader top_file_reader = new StreamReader("C:\\top_coordinate_add.txt"); ArrayList frontFeature = new ArrayList(); //前台sketch的特征符 (front)
ArrayList sideFeature = new ArrayList(); //前台sketch的特征符 (side)
ArrayList topFeature = new ArrayList(); //前台sketch的特征符 (top) while (file_count < )
{
string front_file_route = "";
front_file_route = front_file_reader.ReadLine(); string side_file_route = "";
side_file_route = side_file_reader.ReadLine(); string top_file_route = "";
top_file_route = top_file_reader.ReadLine(); string front_coordinate_str = "";
//char[] front_buffer = new char[30000];
StreamReader front_reader = new StreamReader(front_file_route);
//front_reader.Read(front_buffer,0,29999);
front_coordinate_str = front_reader.ReadLine();
//string front_coordinate_str = new string(front_buffer);
front_reader.Close(); string side_coordinate_str = "";
StreamReader side_reader = new StreamReader(side_file_route);
side_coordinate_str = side_reader.ReadLine();
side_reader.Close(); string top_coordinate_str = "";
StreamReader top_reader = new StreamReader(top_file_route);
top_coordinate_str = top_reader.ReadLine();
top_reader.Close(); bool result = WordStreamMatching.getInstance().matching(front_coordinate_str, side_coordinate_str, top_coordinate_str, ref frontFeature, ref sideFeature, ref topFeature); if (!result)
MessageBox.Show(""); file_count++;
}

C#读写文本和连接数据库的更多相关文章

  1. 背水一战 Windows 10 (89) - 文件系统: 读写文本数据, 读写二进制数据, 读写流数据

    [源码下载] 背水一战 Windows 10 (89) - 文件系统: 读写文本数据, 读写二进制数据, 读写流数据 作者:webabcd 介绍背水一战 Windows 10 之 文件系统 读写文本数 ...

  2. iOS 9应用开发教程之多行读写文本ios9文本视图

    iOS 9应用开发教程之多行读写文本ios9文本视图 多行读写文本——ios9文本视图 文本视图也是输入控件,与文本框不同的是,文本视图可以让用户输入多行,如图2.23所示.在此图中字符串“说点什么吧 ...

  3. python_py2和py3读写文本区别

    python2和python3的区别? python 2  str             对应      python3 bytes python 2 uincode            对应   ...

  4. 零基础学python-3.7 还有一个程序 python读写文本

    今天我们引入另外一个程序,文件的读写 我们先把简单的程序代码贴上.然后通过我们多次的改进.希望最后可以变成一个简单的文本编辑器 以下是我们最简单的代码: 'crudfile--读写文件' def re ...

  5. Python之读写文本数据

    知识点不多 一:普通操作  # rt 模式的 open() 函数读取文本文件 # wt 模式的 open() 函数清除覆盖掉原文件,write新文件 # at 模式的 open() 函数添加write ...

  6. Python-py2和py3读写文本区别

    python2和python3的区别? python 2  str             对应      python3 bytes python 2 uincode            对应   ...

  7. delphi 读写文本

    将字符串写入txt文档,读取txt文档中的内容. //一次写字符串到文本文件,每次都会将原来的内容替换掉. procedure FilePutContents(f,s:String); // f为文件 ...

  8. 读写文本(.txt)文件 .NET

    http://www.cnblogs.com/jx270/archive/2013/04/14/3020456.html (一) 读取文件 如果你要读取的文件内容不是很多,可以使用 File.Read ...

  9. Unity 读写文本 文件

    1. LitJson的使用 https://blog.csdn.net/qq_35669619/article/details/78928966 https://blog.csdn.net/qq_14 ...

随机推荐

  1. 13-mv 命令总结

  2. Oracle Temp表空间切换

    来源于:  http://www.2cto.com/database/201507/418564.html 一.TEMP表空间作用 临时表空间主要用途是在数据库进行排序运算.管理索引.访问视图等操作时 ...

  3. [oracle] 解决ORA-30036:无法按8扩展段(在还原表空间‘XXXX’中)

    select * from dba_data_files awhere a.TABLESPACE_NAME='UNDOTBS' alter tablespace UNDOTBS add datafil ...

  4. Ubuntu下tftp服务器的搭建

    参考博客:http://blog.chinaunix.net/uid-26495963-id-3206829.html 1. 安装 $ apt-get install tftp-hpa tftpd-h ...

  5. python 中的sort 和java中的Collections.sort()函数的使用

    x=[1,2,3] x.sort()对的,x这个都变了 y=x.sort()错误 y=sorted(x)对的,x拍好序的一个副本 python中用匿名函数和自定义函数排序:(很奇怪的是比较函数返回的是 ...

  6. JAVA1种C++3种继承方式

    JAVA中只有一种public继承

  7. mysql之旅【第一篇】

    1,基本操作 create databades 数据库名: #创建数据库 show databases; #显示存在的数据库 drop database 数据库名字 #删除数据库 2,数据库存储引擎介 ...

  8. hdu1161 欧拉路

    欧拉路径是指能从一个点出发能够“一笔画”完整张图的路径:(每条边只经过一次而不是点) 在无向图中:如果每个点的度都为偶数 那么这个图是欧拉回路:如果最多有2个奇数点,那么出发点和到达点必定为该2点,那 ...

  9. 安装 Couchbase 服务器

    一. 下载安装包 首先,到官网下载安装包:http://www.couchbase.com/ 下载的地址:http://www.couchbase.com/download 选择 Windows 的版 ...

  10. 新版汉诺塔(UVa10795 - A Different Task)

    题目介绍: 标准的汉诺塔上有n个大小各异的盘子.现给定一个初始局面(见图1),求它到目标局面(见图2)至少需要移动多少步? 移动规则:一次只能移动一个盘子:且在移动盘子之前,必须把压在上面的其他盘子先 ...