Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6680639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:29:55+00:00 2026-05-26T04:29:55+00:00

I’ve found out how to import a CSV into my Access database via another

  • 0

I’ve found out how to import a CSV into my Access database via another question. But in the answer there is no information on how to target specific columns upon import. How can I be sure that the correct columns from the CSV get placed into the correct columns in my database?

I need to be able to edit/add-to the column values as they get imported using classic ASP. Examples:

  • The 4th column in the CSV is a userid, I need to be able to add "@domain.com" to the end as it enters the database for an email column.
  • The 6th column is a classification: if it’s value is "Teacher" then, as it gets imported, I need to change it to "Classroom".

I’m working with some old code & DB’s that I didn’t create. Believe me, I’d be using something else if I could, so no pot-shots for using MS Access, please.

I guess this whole thing boils down to this:

  • if the previous question’s answer really allows me to treat the CSV the same as a db table, then how can I select the columns as in a real db table?

// Update:

I’ve set everything up how I believe it should be, but I’m receiving an error:

ADODB.Recordset error '800a0bb9'

Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

/datazone_bkup/Rollover/importTeachers.asp, line 12

line 12: CSV.open "SELECT * FROM teachers.csv", conn

My full code is as follows:

strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &_
             Server.MapPath("\path\to\file") & ";Extended Properties='text;HDR=no;FMT=Delimited';"

Set connCSV = Server.CreateObject("ADODB.Connection")
connCSV.Open strConn

Set CSV = Server.CreateObject("ADODB.recordset")
    CSV.open "SELECT * FROM teachers.csv", conn

    do until CSV.eof
        UserName = CSV.Fields(4)
        LastName = CSV.Fields(1)
        FirstName = CSV.Fields(2)
        MiddleName = CSV.Fields(3)
        School = CSV.Fields(5)
        if CSV.Fields(6) = "Teacher" then
            SecLevel = "Classroom"
        end if
        Active = "Yes"
        TeacherNumber = rsCSV.Fields(0)
        rsCSV.movenext
        
        sql = "INSERT INTO tblTeacher (UserName, LastName, FirstName, MiddleName, School, SecLevel, Active, TeacherNumber) " &_
                "VALUES (" &_
                    "'" & UserName & "','" & LastName & "','" & FirstName & "','" & MiddleName & "'," &_
                    "'" & School & "','" & SecLevel & "','" & Active & "','" & TeacherNumber & "'" &_
                ")"

        on error resume next
        conn.execute(sql)
    loop

@HansUp, when I tried using the ! as in rsDB!UserName, I received a Syntax Error. So I went back to setting variables for the CSV column values.

Again, thanks for any help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:29:56+00:00Added an answer on May 26, 2026 at 4:29 am

    As in the previous question you linked, let’s assume you have opened an ADO recordset with the CSV contents. You can open a second ADO recordset for the Access destination table.

    If the CSV file includes column names, you can loop through its recorset rows and insert its values into the destination recordset. If the CSV recordset is rsCSV and the recorset for the destination table is rsDB …

    Do While Not rsCSV.EOF
        rsDB.AddNew
        rsDB!userid = rsCSV!userid & "@domain.com"
        If rsCSV!classification = "Teacher" Then
            rsDB!classification = "Classroom"
        Else
            rsDB!classification = rsCSV!classification
        End If
        rsDB.Update
        rsCSV.MoveNext
    Loop
    

    If the CSV doesn’t include column names, you can still do it but would need to use the field’s ordinal position in the fields collection. Those position numbers are zero-based, so 3 for the 4th column, and so forth.

    Do While Not rsCSV.EOF
        rsDB.AddNew
        rsDB!userid = rsCSV.Fields(3) & "@domain.com"
        If rsCSV.Fields(5) = "Teacher" Then
            rsDB!classification = "Classroom"
        Else
            rsDB!classification = rsCSV.Fields(5)
        End If
        rsDB.Update
        rsCSV.MoveNext
    Loop
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.