C# 连结access
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
/// <summary>
/// DB 的摘要描述
/// </summary>
public class DB
{
OleDbConnection conn = null;
OleDbCommand cmd = new OleDbCommand();
public DB()
{
//
// TODO: 在此加入建構函式的程式碼
//
string dbname = System.Web.HttpContext.Current.Server.MapPath("DB_App/netData.aspx");
string conStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+dbname;
conn = new OleDbConnection(conStr);
}
public OleDbConnection getConn()
{
if (conn.State == ConnectionState.Closed)
conn.Open();
return conn;
}
public void clear()
{
if(conn.State==ConnectionState.Open)
conn.Close();
}
public string getScalar(string strSql)
{
cmd.Connection = getConn();
cmd.CommandText = strSql;
string result = cmd.ExecuteScalar().ToString();
clear();
return result;
}
public int getReturnNum(string strSql)
&nb
相关文档:
已知有一个XML文件(bookstore.xml)如下:
<?xml version="1.0" encoding="gb2312"?>
<bookstore>
<book genre="fantasy" ISBN="2-3631-4">
<title>Oberon's Legacy</title>
<author>Corets, Eva</author>
<price>5.95</price& ......
刚开始很不习惯c#的风格,哎,先入为主啊,delphi习惯了,{}代替begin/end太扎眼。
属性方法的宣告和代码在一起,没有像delphi分interface/implementation,感觉太乱,都不知道一个class到底有几个方法。
每个属性和方法前面都要单独写private/protected/public,老天,c#是delphi之父设计的揶,怎么不学delphi写一个就行 ......
xml文件:
<?xml version="1.0" encoding="utf-8" ?>
<bookstore>
<book>
<title lang="eng">Harry Potter</title>
<price>29.99</price>
</book>
<book>
......
现在很多软件都是以xml文件作为数据源,而很多数据工具如pb等却只能另存为txt、excel等格式,为此需要一工具能将txt文本转换成xml文件。google了一下,没找到合适的,冲动之下用C#写了一个txt文本转xml格式文本的小程序,代码如下。
新建一个w ......
C# word转换成HTML
添加com引用Microsoft word 11.0 Object Library
添加using System.Threading;using System.IO;
//实例化一个Word
Microsoft.Office.Interop.Word.ApplicationClass appclass = new Microsoft.Office.Inter ......