资源简介
定时读取excel更新到数据库,用2003的excel
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using System.Windows.Forms;
namespace update_material_shortage
{
class database
{// 连接数据源
private SqlConnection con;
///
/// 打开数据库连接.
///
public void Open()
{
// 打开数据库连接
if (con == null)
{
con = new SqlConnection(“server=192.168.0.111;uid=sa;pwd=hentech;database=oa;“);
}
if (con.State == ConnectionState.Closed)
{
try
{
///打开数据库连接
con.Open();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
///关闭已经打开的数据库连接
}
}
}
///
/// 关闭数据库连接
///
public void Close()
{
///判断连接是否已经创建
if (con != null)
{
///判断连接的状态是否打开
if (con.State == ConnectionState.Open)
{
con.Close();
}
}
}
///
/// 释放资源
///
public void Dispose()
{
// 确认连接是否已经关闭
if (con != null)
{
con.Dispose();
con = null;
}
}
///
/// 执行存储过程,无返回值,add by hins 2013.07.09
///
/// sql语句
public void RunSql(string strsql)
{
Open();
SqlCommand cmd = new SqlCommand(strsql con);
cmd.CommandType = CommandType.Text;
try
{
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
Close();
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 57344 2013-07-15 10:08 update material shortage\update material shortage\bin\Debug\Interop.VBIDE.dll
文件 3 2013-07-15 10:33 update material shortage\update material shortage\bin\Debug\shortage_log.txt
文件 77824 2013-07-15 11:33 update material shortage\update material shortage\bin\Debug\update material shortage.exe
文件 32256 2013-07-15 11:33 update material shortage\update material shortage\bin\Debug\update material shortage.pdb
文件 5632 2005-12-08 14:51 update material shortage\update material shortage\bin\Debug\update material shortage.vshost.exe
文件 57344 2013-07-15 10:52 update material shortage\update material shortage\bin\Release\Interop.VBIDE.dll
文件 5 2013-07-15 11:57 update material shortage\update material shortage\bin\Release\shortage_log.txt
文件 77824 2013-07-17 16:53 update material shortage\update material shortage\bin\Release\update material shortage.exe
文件 30208 2013-07-17 16:53 update material shortage\update material shortage\bin\Release\update material shortage.pdb
文件 5632 2005-12-08 14:51 update material shortage\update material shortage\bin\Release\update material shortage.vshost.exe
文件 2408 2013-07-15 10:17 update material shortage\update material shortage\databa
文件 9520 2013-07-17 16:54 update material shortage\update material shortage\Form1.cs
文件 4689 2013-07-15 11:33 update material shortage\update material shortage\Form1.Designer.cs
文件 86968 2013-07-15 11:33 update material shortage\update material shortage\Form1.resx
文件 57344 2013-07-15 10:08 update material shortage\update material shortage\obj\Debug\Interop.VBIDE.dll
文件 4608 2013-07-15 11:19 update material shortage\update material shortage\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll
文件 842 2013-07-15 11:33 update material shortage\update material shortage\obj\Debug\update material shortage.csproj.GenerateResource.Cache
文件 679 2013-07-15 10:08 update material shortage\update material shortage\obj\Debug\update material shortage.csproj.ResolveComReference.cache
文件 77824 2013-07-15 11:33 update material shortage\update material shortage\obj\Debug\update material shortage.exe
文件 32256 2013-07-15 11:33 update material shortage\update material shortage\obj\Debug\update material shortage.pdb
文件 54256 2013-07-15 11:33 update material shortage\update material shortage\obj\Debug\update_material_shortage.Form1.resources
文件 180 2013-07-15 10:12 update material shortage\update material shortage\obj\Debug\update_material_shortage.Properties.Resources.resources
文件 57344 2013-07-15 10:52 update material shortage\update material shortage\obj\Release\Interop.VBIDE.dll
文件 4608 2013-07-17 16:54 update material shortage\update material shortage\obj\Release\TempPE\Properties.Resources.Designer.cs.dll
文件 842 2013-07-15 11:39 update material shortage\update material shortage\obj\Release\update material shortage.csproj.GenerateResource.Cache
文件 826 2013-07-17 16:53 update material shortage\update material shortage\obj\Release\update material shortage.csproj.ResolveComReference.cache
文件 77824 2013-07-17 16:53 update material shortage\update material shortage\obj\Release\update material shortage.exe
文件 30208 2013-07-17 16:53 update material shortage\update material shortage\obj\Release\update material shortage.pdb
文件 54256 2013-07-17 16:53 update material shortage\update material shortage\obj\Release\update_material_shortage.Form1.resources
文件 180 2013-07-17 16:53 update material shortage\update material shortage\obj\Release\update_material_shortage.Properties.Resources.resources
............此处省略24个文件信息
- 上一篇:linux驱动编写ppt
- 下一篇:27MHZ 无线数据收发器电路图
评论
共有 条评论