Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Export excel data to SQL server in ASP

Export excel data to SQL server in ASP

Scheduled Pinned Locked Moved Web Development
databasesql-serversysadminhelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    priyaahh
    wrote on last edited by
    #1

    Hi Friends, Kindly help me for this. I wanted to export of excel data to table in sql server. I have to compare the column name in excel and table then export that column then next column. Like this i wanted this export. Please help... Thanks in Advance, Regards,

    P 1 Reply Last reply
    0
    • P priyaahh

      Hi Friends, Kindly help me for this. I wanted to export of excel data to table in sql server. I have to compare the column name in excel and table then export that column then next column. Like this i wanted this export. Please help... Thanks in Advance, Regards,

      P Offline
      P Offline
      Poonam Gandash
      wrote on last edited by
      #2

      ' Path to excel file z="uploadasp/contact_data.xls;" Path = Server.MapPath(z) SQL_Query = "SELECT * FROM [Commercial$]" Driver ="{Microsoft Excel Driver (*.xls)}" DataSource = "DBQ=" & Path & ";" DataSource = DataSource & "DefaultDir=" & Path & ";" DataSource = DataSource & "Driver=" & Driver & ";" DataSource = DataSource & "FIL=excel 5.0;ReadOnly=1;" Set MyConn =Server.CreateObject("ADODB.Connection") MyConn.ConnectionTimeout = 15 MyConn.CommandTimeout = 30 MyConn.Open DataSource 'Set MyConn = Server.CreateObject("ADODB.Connection") 'Set MyConn = Server.CreateObject("ADODB.Recordset") 'strBaseFilePath ="uploadasp/contact_data.xls" 'MyConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _ '"Data Source=" & Server.MapPath(strBaseFilePath) & ";" & _ '"Extended Properties=""Excel 8.0;""" 'RS.Open SQL_Query, MyConn, adOpenStatic 'Lets loop through the data and output it into a HTML table Set RS = MyConn.Execute(SQL_Query) IF RS.EOF THEN 'There is no data to show tot=0 ELSE 'Lets output the field names ' FOR EACH Field IN RS.Fields ' NEXT 'Now we will output each row of the data tot=0 tota=0 DO WHILE NOT RS.EOF if rs.fields(0)<>"" then Set rs4 = Server.CreateObject("ADODB.Recordset") rs4.open "select * from data where 1<>1",Con,1,3 rs4.addnew IF rs.Fields(0)<>"" THEN RS4("name")=rs.Fields(0) IF rs.Fields(1)<>"" THEN RS4("surname")=rs.Fields(1) IF rs.Fields(2)<>"" THEN RS4("primary_email")=rs.Fields(2) rs4.UPDATE end if RS.MoveNext LOOP END IF RS.Close Set RS = nothing MyConn.Close Set MyConn = nothing =================== Hope this code will help

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups