<%
'On Error Resume Next
'导入
Excel电子表格数据到SQL Sever数据库 By Dicky 2004-12-27 16:41:12 QQ:25941
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数据库连接
Function Get_EMP_CnName(NTACCNT)
'根据用户NT帐号得到用户中文名
Dim Sql,Rs
Sql = "Select EMP_CNAME From RF_EMPLOYEE Where EMP_NTACCNT='"&NTACCNT&"'"
Set Rs = Server.CreateObject("Adodb.RecordSet")
Rs.Open Sql,SqlConn,1,1
If Rs.Eof Then
Get_EMP_CnName = ""
Else
Get_EMP_CnName = Rs("EMP_CNAME")
End If
Rs.Close
Set Rs = Nothing
End Function %>
导入Excel电子表格数据到SQL Sever数据库导入Excel电子表格数据到SQL Sever数据库