Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Here's what I ended up using</strong> <em>(in case someone else runs into an issue like this)</em>: <br/>Thanks everyone for your help.</p> <pre class="lang-vb prettyprint-override"><code>Server.ScriptTimeout = 2147483647 Response.Buffer = False on error resume next dim conn1, conn, rs, updatedUser, updatedDate, filePath, dim deactivateSQL, csvConn, connCSV, csv, sql dim csvID, csvSSN, csvLast, csvFirst, csvMiddle dim csvGender, csvScl, csvGrd, csvCls, dbCls updatedUser = Request.Cookies("UserN") updatedDate = date() &amp; " " &amp; time() filePath = "\path\to\file" ' --- Connect to DZ database set conn1=Server.CreateObject("ADODB.Connection") conn1.Provider="Microsoft.Jet.OLEDB.4.0" conn1.Open "E:/path/to/database.mdb" ' --- Deactivate ALL students deactivateSQL = "UPDATE tblStudent SET Active=False " &amp;_ "AND lastUpdatedUser='" &amp; updatedUser &amp; "' "&amp;_ "AND lastUpdatedDate='" &amp; updatedDate &amp; "';" conn1.execute(deactivateSQL) conn1.close ' --- Connect to Students.CSV exported by iNOW csvConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &amp;_ Server.MapPath(filePath) &amp;_ ";Extended Properties='text;HDR=no;FMT=Delimited';" Set connCSV = Server.CreateObject("ADODB.Connection") connCSV.Open csvConn Set csv = Server.CreateObject("ADODB.recordset") csv.open "SELECT * FROM Students.csv", connCSV ' --- Begin looping through Students.csv do until csv.eof ' --- Get Students.csv Column Values csvID = csv.fields(0) if isnull(csv.fields(1)) then csvSSN = NULL else csvSSN = csv.fields(1) end if csvLast = replace(csv.fields(2), "'", "") csvFirst = replace(csv.fields(3), "'", "") ' --- Using IsNull() fixed the 2nd problem ' --- I was having after updating the question if isnull(csv.fields(4)) then csvMiddle = csv.fields(4) else csvMiddle = replace(csv.fields(4), "'", "") end if csvGender = csv.fields(5) csvScl = csv.fields(6) csvGrd = csv.fields(7) csvCls = csv.fields(8) ' --- Connect to database set conn=Server.CreateObject("ADODB.Connection") conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Open "E:/path/to/database.mdb" set rs=Server.CreateObject("ADODB.Recordset") rs.open "SELECT * FROM tblStudent " &amp;_ "WHERE StudentID='" &amp; csvID &amp; "';", conn if rs.bof and rs.eof then ' --- if rs.bof &amp; rs.eof, the csvID is NOT in the table ' --- Add the new csvID to DB, we'll add the rest in ' --- the UPDATE statement below conn.execute("INSERT INTO tblStudent (StudentID) " &amp;_ "VALUES ('" &amp; csvID &amp; "');") ' --- Set to 0 since it's supposed to be a number dbCls = 0 else ' --- Get tblStudents.Class from existing record dbCls = rs.fields("Class") end if ' --- UPDATE the table with the appropriate info sql = "UPDATE tblStudent SET " &amp;_ "Active=True, " &amp;_ "SSN=" &amp; csvSSN &amp; ", " &amp;_ "LastName='" &amp; csvlast &amp; "', " &amp;_ "FirstName='" &amp; csvFirst &amp; "', " &amp;_ "MiddleName='" &amp; csvMiddle &amp; "', " &amp;_ "Gender='" &amp; csvGender &amp; "', " &amp;_ "School=" &amp; csvScl &amp; ", " &amp;_ "GradeLvl=" &amp; csvGrd &amp; ", " &amp;_ "Class=" &amp; csvCls &amp; ", " &amp;_ "PrevClass1='" &amp; dbCls &amp; "', " &amp;_ "lastUpdatedUser='" &amp; updatedUser &amp; "', " &amp;_ "lastUpdatedDate='" &amp; updatedDate &amp; "' " &amp;_ "WHERE StudentID='" &amp; csvID &amp; "';" conn.execute(sql) csv.movenext loop if error&lt;&gt;0 then response.cookies("updated") = "no" response.cookies("updated").Expires = dateadd("s", 2, now()) response.redirect("step-5.asp") else response.cookies("updated") = "yes" response.cookies("updated").Expires = dateadd("s", 2, now()) response.redirect("step-6.asp") end if </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload