[C#] 纯文本查看 复制代码 /*
* Created by SharpDevelop.
* User: Administrator
* Date: 2012-9-10
* Time: 11:26
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.Generic;
using System.Collections;
using System.Data.OleDb;
using System.Data;
using System.Text;
namespace jk
{
class MainClass
{
public static void Main(string[] args)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("简朴电话本2.1");
Console.WriteLine("博乐市电子政务办 2012年8月");
Console.WriteLine("CopyRight(c) 2012 zjmsoft All Rights Reserved"+"\n");
while(true)
{
Console.WriteLine("请输入关键字,按回车键执行查询。");
string py=Console.ReadLine();
string s="";
if(py=="end" || py=="")
break;
string connStr, selectCmd;
connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=dhb.mdb";
selectCmd = "Select pyname,name,party,telephone,mobilephone From dh where pyname like '%" + py.Trim().ToString() + "%' or telephone like '%" + py.Trim().ToString() + "%' or party like '%" + py.Trim().ToString() + "%' or mobilephone like '%" + py.Trim().ToString() + "%' or name like '%" + py.Trim().ToString() + "%'";
OleDbConnection conn;
conn = new OleDbConnection(connStr);
conn.Open();
OleDbCommand cmd=new OleDbCommand(selectCmd,conn);
OleDbDataReader dr=cmd.ExecuteReader();
while(dr.Read())
{
s += dr["name"]+" "+dr["party"]+" "+dr["telephone"]+" "+dr["mobilephone"]+"\n";
Console.WriteLine(s);
}
Console.WriteLine("查询完毕,按回车继续查询");
Console.ReadLine();
}
}
}
}
|