Import Excel spreadsheet data to SQL Sever database

Source: Internet
Author: User
<%
' On Error Resume Next
' Import Excel spreadsheet data to SQL Sever database by Dicky 2004-12-27 16:41:12 qq:25941
Function Open_conn (Sqldatabasename,sqlpassword,sqlusername,sqllocalname,sqlconn)
' Create a database connection object and open the database connection
Dim ConnStr
' SQL Server database connection parameters: Database name, user password, username, connection name (local locally, field 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 "Data connection Error!"
Response.End
End If
End Function
Function Close_conn (sqlconn)
' Close the database connection and clear the database connection object
If IsObject (sqlconn) Then
Sqlconn.close
Set sqlconn = Nothing
End If
End Function
Call Open_conn ("Shat_edg", "", "sa", "(local)", sqlconn) ' Open SQL Server database connection
Function Get_emp_cnname (ntaccnt)
' User's Chinese name according to user NT account
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%>
<title> import Excel spreadsheet data to SQL Sever database </title>
<body bgcolor= "#ACD9AF" >
<center><b> import Excel spreadsheet data to SQL Sever database </b></center>
<form method= "POST" Name= "Form1" >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.