最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
excel导入sql
时间:2022-07-02 23:19:23 编辑:袖梨 来源:一聚教程网
<%
'On Error Resume Next
'导入Excel电子表格数据到SQL Sever数据库 By Dicky 2004-12-27 16:41:12
Function Open_Conn(SqlDatabaseName,SqlPassword,SqlUsername,SqlLocalName,SqlConn)
'创建数据库连接对象并打开数据库连接
Dim ConnStr
'SQL Server数据库连接参数:数据库名、用户密码、用户名、连接名(本地用local,外地用IP)
ConnStr = "Provider=Sqloledb; User ID=" & SqlUsername & "; Password=" & SqlPassword & "; Initial Catalog = " & SqlDatabaseName & "; Data Source=" & SqlLocalName & ";"
Set SqlConn = Server.CreateObject("ADODB.Connection")
SqlConn.Open ConnStr
If Err Then
Err.Clear
Set SqlConn = Nothing
Response.Write "数据连接错误!"
Response.End
End If
End Function
Function Close_Conn(SqlConn)
'关闭数据库连接并清除数据库连接对象
If IsObject(SqlConn) Then
SqlConn.Close
Set SqlConn = Nothing
End If
End Function
Call Open_Conn("Shat_EDG","","sa","(local)",SqlConn) '打开本地SQL Server数据库连接
Call Open_Conn("Shat_EDG","","sa","ssh03",SqlConn1) '打开远程SQL Server数据库连接
Function Get_EMP_CnName(NTACCNT)
'根据用户NT帐号得到用户中文名
Dim Sql1,Rs1
Sql1 = "Select EMP_CNAME From RF_EMPLOYEE Where EMP_NTACCNT='"&NTACCNT&"'"
Set Rs1 = Server.CreateObject("Adodb.RecordSet")
Rs1.Open Sql1,SqlConn1,1,1
If Rs1.Eof Then
Get_EMP_CnName = ""
Else
Get_EMP_CnName = Rs1("EMP_CNAME")
End If
Rs1.Close
Set Rs1 = Nothing
End Function %>