資源簡介
定時讀取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 無線數據收發器電路圖
評論
共有 條評論