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. thinkphp 配置多数据库

    1配置文件中配置另一数据库连接信息 例如: 'TestModelConfig' => array( //'配置项'=>'配置值' 'DB_TYPE' => 'mysql', // 数 ...

  2. oracle 10g编程

    一.概述 1.sql语言特点 sql语言采用集合操作方式,对数据的处理是成组进行的,而不是一条一条处理,听过使用集合操作方式,可以家加快数据的处理速度. 执行sql语句时每次只能发送并处理一条语句.如 ...

  3. 使用js和jq去掉左右空格方法

    <!DOCTYPE html><html> <head> <meta charset="UTF-8"> <script src ...

  4. SQL 常用函数及示例

    --SQL 基础-->常用函数 --================================== /* 一.函数的分类 SQL函数一般分为两种 单行函数 基于单行的处理,一行产生一个结果 ...

  5. java中的hashSet和Treeset的分析

    hashset中的元素 treeset中的元素要实现comparable接口

  6. Xcode插件VVDocumenter Alcatraz KSImageNamed等安装

    今天安装VVDocumenter,总是不起作用...所以用Alcatraz...下面介绍下Alcatraz 一.Alcatraz Alcatraz 是一款 Xcode的插件管理工具,可以用来管理XCo ...

  7. Java反编译插件JadClipse

    Java反编译是很容易的,现在就介绍一个反编译插件,以后我们通过Ctrl+鼠标左键查看源码就容易得多了,不用再担心源码找不到了,配置过程很简单的. 准备: 1.下载JadClipse(jar文件,ec ...

  8. hadoop报错:WARN mapred.JobClient: Error reading task outputNo route to host

    解决方案: /etc/sysconfig/network/etc/hosts$hostname 这三处的主机名都要一样. 具体参考:http://blog.itpub.net/28254374/vie ...

  9. 【poj3461】 Oulipo

    http://poj.org/problem?id=3461 (题目链接) 题意 求一个字符串在另一个字符串中出现的次数. Solution KMP裸题,太久没写过了,都忘记怎么求next数组了..水 ...

  10. codeforces 342E :Xenia and Tree

    Description Xenia the programmer has a tree consisting of n nodes. We will consider the tree nodes i ...