資源簡(jiǎn)介
定時(shí)讀取excel更新到數(shù)據(jù)庫(kù),用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
????{//?連接數(shù)據(jù)源
????????private?SqlConnection?con;
????????///?
????????///?打開(kāi)數(shù)據(jù)庫(kù)連接.
????????///?
????????public?void?Open()
????????{
????????????//?打開(kāi)數(shù)據(jù)庫(kù)連接
????????????if?(con?==?null)
????????????{
????????????????con?=?new?SqlConnection(“server=192.168.0.111;uid=sa;pwd=hentech;database=oa;“);
????????????}
????????????if?(con.State?==?ConnectionState.Closed)
????????????{
????????????????try
????????????????{
????????????????????///打開(kāi)數(shù)據(jù)庫(kù)連接
????????????????????con.Open();
????????????????}
????????????????catch?(Exception?ex)
????????????????{
????????????????????MessageBox.Show(ex.Message);
????????????????}
????????????????finally
????????????????{
????????????????????///關(guān)閉已經(jīng)打開(kāi)的數(shù)據(jù)庫(kù)連接
????????????????}
????????????}
????????}
????????///?
????????///?關(guān)閉數(shù)據(jù)庫(kù)連接
????????///?
????????public?void?Close()
????????{
????????????///判斷連接是否已經(jīng)創(chuàng)建
????????????if?(con?!=?null)
????????????{
????????????????///判斷連接的狀態(tài)是否打開(kāi)
????????????????if?(con.State?==?ConnectionState.Open)
????????????????{
????????????????????con.Close();
????????????????}
????????????}
????????}
????????///?
????????///?釋放資源
????????///?
????????public?void?Dispose()
????????{
????????????//?確認(rèn)連接是否已經(jīng)關(guān)閉
????????????if?(con?!=?null)
????????????{
????????????????con.Dispose();
????????????????con?=?null;
????????????}
????????}
????????///?
????????///?執(zhí)行存儲(chǔ)過(guò)程,無(wú)返回值,add?by?hins?2013.07.09
????????///?
????????///?sql語(yǔ)句
????????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();
????????}
????}
}
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件??????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個(gè)文件信息
評(píng)論
共有 條評(píng)論