excel宏:
随后更新
webservice:
1.创建空应用程序
2.添加web服务
3.创建数据库访问类库DataHelper
sqlserver:
创建数据同步的存储过程
以下是一些需要的代码,比较杂乱,有空再整理整理。
DataFactory.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
namespace DataHelper
{
public class DataFactory
{
/// <summary>
/// 获取数据类型1为sqlserver,2为access
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public static DbHelper GetHelper()
{
string ConnStr = ConfigurationManager.AppSettings["ConnStr"].ToString();
int Dbtype = 1;
Int32.TryParse(ConfigurationManager.AppSettings["DbType"].ToString(), out Dbtype);
switch (Dbtype)
{
case 1:
return new SqlHelper(ConnStr);
case 2:
return new OledbHelper(ConnStr);
default:
return new SqlHelper(ConnStr);
}
}
public static DbHelper GetHelper1()
{
string ConnStr = ConfigurationManager.AppSettings["ConnStr1"].ToString();
int Dbtype = 1;
Int32.TryParse(ConfigurationManager.AppSettings["DbType"].ToString(), out Dbtype);
switch (Dbtype)
{
case 1:
return new SqlHelper(ConnStr);
case 2:
return new OledbHelper(ConnStr);
default:
return new SqlHelper(ConnStr);
}
}
public static DbHelper GetYellowPageHelper()
{
string ConnStr = ConfigurationManager.AppSettings["ConnStrYP"].ToString();
int Dbtype = 1;
Int32.TryParse(ConfigurationManager.AppSettings["DbType"].ToString(), out Dbtype);
switch (Dbtype)
{
case 1:
return new SqlHelper(ConnStr);
case 2:
return new OledbHelper(ConnStr);
default:
return new SqlHelper(ConnStr);
}
}
/// <summary>
/// Discuz数据库
/// </summary>
/// <returns></returns>
public static DbHelper GetYellowPageHelperDNT()
{
string ConnStr = ConfigurationManager.AppSettings["ConnStrDNT"].ToString();
int Dbtype = 1;
Int32.TryParse(ConfigurationManager.AppSettings["DbType"].ToString(), out Dbtype);
switch (Dbtype)
{
case 1:
return new SqlHelper(ConnStr);
case 2:
return new OledbHelper(ConnStr);
default:
return new SqlHelper(ConnStr);
}
}
}
}
DbHelper.cs
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Text;
using System.Collections.Specialized;
namespace DataHelper
{
public abstract class DbHelper
{
/// <summary>
/// 得到数据库链接
/// </summary>
public abstract IDbConnection Connection { get; }
/// <summary>
/// 打开数据库连接;
/// </summary>
public abstract void Open();
/// <summary>
/// 关闭数据库链接;
/// </summary>
public abstract void Close();
/// <summary>
/// 开始一个事务;
/// </summary>
public abstract void BeginTrans();
/// <summary>
/// 提交一个事务;
/// </summary>
public abstract void CommitTrans();
/// <summary>
/// 回滚一个事务;
/// </summary>
public abstract void RollBackTrans();
/// <summary>
/// 执行sql语句,返回受影响集合数
/// </summary>
/// <param name="cmdType">命令类型</param>
/// <param name="cmdText">命令字符串</param>
/// <param name="commandParameters">命令参数</param>
/// <returns></returns>