<% 'On Error Resume Next' Import Excel spreadsheet data to SQL Sever Database by Dicky 2004-12-27 16:41:12 QQ: 25941Function Open_CONN (SqlDatabaseEname, SqllocalName, SqlConn) Creates a database connection object and Open Database Connection DIM ConnStr 'SQL Server Database Connection Parameters: Database Name, User Password, User Name, Connection Name (Local Local, Field IP) Connstr = "Provider = SQLOLDB; 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 "Data connection error!" Response.end end if End function
Function Close_conn (SQLCONN) 'Closing the Database Connection and Clears Database Connection Object If IsObject (Sqlconn) Then Sqlconn.close Set Sqlconn = Nothing End IFEND Function
Call Open_CONN ("Shat_edg", "", "SA", "(local)", "SQLCONN) Opens SQL Server Database Connection
Function Get_EMP_CnName (NTACCNT) 'get the user name Chinese Dim Sql NT user account, 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 xi = nothingnd function%>