|
-
Aug 29th, 2001, 10:25 AM
#1
Thread Starter
New Member
ASP and SQL7 problem
Hi,
Here is a page I am working on (not finished). I am just trying to
print to the page at this point to check the progress. I am having
trouble when it comes to the blob at the end. I am just trying to
display the blob as text right now to to make sure I am getting
something in the recordset.
What I am trying to accomplish: Take data from a remote server (sql7)
and update a local database. If a row exists (id) then update, if it doesn't,
then insert.
Any help is appreciated!
<!-- #include file ="../../scripts/velmlsdsn.asp" -->
<!-- #include file ="../../scripts/nhmlsdsn.asp" -->
<!-- #include file="../../scripts/adovbs.inc" -->
<%
'Option Explicit
On Error Resume Next
Dim oConn, oRS, last_com_date ,sMode, rsTemp, rsTemp2, mySQL, mySQL2
sScriptPath = Request.ServerVariables("SCRIPT_NAME")
sMode = Request.Form("EVENT")
last_com_date = Request.form("last_com_date")
response.write sMode
Response.write "<BR>" & last_com_date
If IsEmpty(Request.Form("EVENT")) then
sButtonMsg = "Procede With Update"
Get_Last_Com()
else
response.write "<BR>ready to go to add_info"
Add_Info(last_com_date)
end if
Sub Get_Last_Com()
sMode = "Update"
mySQL2 = "select min(dateadd(hour,-1,last_com_date)) last_com_date from mls_area"
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open velmlsdsn '"Provider=SQLOleDB;server=servername;Initial Catalog=pubs;uid=sa;pwd="
set rsTemp = oConn.Execute(mySQL2) '"select min(dateadd(hour,-1,last_com_date)) as last_com_date from mls_area"
response.write "<br> mySQL2 = '" & mySQL2 & "'"
if rsTemp.EOF then
Response.Write "<BR>Error Occurred Executing Query...<BR>"
Response.Write "<BR>No record found<BR>"
oConn.Close
Set oConn = Nothing
ObjectContext.SetAbort
Response.End
else
%>
<BODY BGCOLOR=FFFFFF onLoad="document.updateMLS.last_com_date.focus()">
<FORM NAME="updateMLS" ACTION="<%=sScriptPath%>" METHOD=POST>
<Table>
<TR>
<TD><FONT color=#ff0000><STRONG>Last Update Date: </STRONG></FONT>
<INPUT name="last_com_date" value="<%=rsTemp("last_com_date")%>" size=100 style="HEIGHT: 22px; WIDTH: 317px">
<BR>If you wish a different start date/time, please enter it in the same format.<BR>
</TD>
</TR>
</table>
<input type="hidden" name="EVENT" id="EVENT" value="<%=sMode%>">
<FONT FACE="Verdana" SIZE="2">
<INPUT TYPE=SUBMIT VALUE="<% =sButtonMsg %>"></FONT>
<input type="reset" value="Reset Form"><BR><BR>
<%
'Response.Write "<BR>Query Completed Successfully...<BR>"
ObjectContext.SetComplete
End If
oConn.Close
Set oConn = Nothing
'oConn.Close
'Response.Write "<BR>Connection Closed Successfully...<BR>"
'set oConn = Nothing
'Response.Write "<BR>Test Completed Successfully...<BR>"
%> </Form><%
End Sub
Sub Add_Info(last_com_date)
mySQL2 = ""
Insert_flds = "id, type, mod_date_time, p_mod_date_time, web, class, status, class_status, c_type, area, street_no, street_name, town, zip_code, county, near, latitude, longitude, book, page, map, lot, block, map_blk_lot, subdivision, list_date, expire_date, pending_date, sold_date, with_date, original_price, list_price, selling_price, s_ag_fee, b_ag_fee, t_ag_fee, fee_var, coop_feex, var_comm_yn, ref_fee, finance_terms, taxes, assessment, assess_yr, tax_years, tax_rate, lister_board_code, lister_firm_code, lister_firm_name, lister_office_code, lister_office_name, lister_agent_code, lister_agent_name, lister_phone, selling_firm_code, selling_firm_name, selling_office_code, selling_office_name, selling_agent_code, selling_agent_name, ref_office, appr_name, appr_phone, features, remark1, remark5, remark10, open_house, oh_start_date, oh_end_date, oh_desc, advertised, photo, user_fld1_label, user_fld2_label, user_fld3_label, user_fld4_label, user_fld5_label, user_fld1, user_fld2, user_fld3, user_fld4, user_fld5, owner, mls_zone, flood_zone, surveyed, k_out, lot_size, lot_size_acres, school_district, high_school, midl_school, elem_school, seasonal, sump, frontage, water_body, water_frontage, wf_owned, wf_shared, color, glaag, year_built, age, rooms, bedrooms, baths, lavs, baths3_4, tot_baths, bath_level, lav_level, fireplace_level, bath3_4_level, found_size, dr_size, fr_size, lr_size, kt_size, bd1_size, bd2_size, bd3_size, bd4_size, bd5_size, ot_size, building_no, floor_no, unit_no, nof_units, rent_u1, rent_u2, rent_u3, rent_u4, rent_u5, rent_u6, nof_1br, nof_2br, nof_3br, nof_cars, nof_dr_unit, nof_wh_unit, heating_units, heat_unit, elec_unit, water_unit, sewer_unit, nof_parkings, nof_ranges, nof_frig, owner_occ, deed_coven, deed_type, mb_anchor, mb_park_apprvl, mb_park, mb_fee, mb_xfee, mb_make, mb_serial, mb_model, acres, mortgagee, loan_points, condo_fee, sec_deposit, tax_reduction, lease, prime_use, gross_income, annual_expenses, insurance_exp, loan_amnt, traffic_cnt, building_size, manuf_sf, available_sf, office_sf, other_sf, retail_sf, warehse_sf, ceiling_height, grantee_name, garage_type, pole_no, cable, cam, phone_service, max_flc, noi, cogs, sff, goi, update_origin, air_cond, door_height, nof_drive_doors, nof_docks, rail_serv, signage, nof_floors, class5, class7, have_want, lease_amnt_per, lease_price, mgmt_res, price_type, vac, exclusion1, exclusion2, lister_office_phone, glaaga, glaagb, llot_size, n_ag_gee, den_size, parking, owner_phone, source_sf, surveyed_by, power_co, permit_no, open_space, stg_size, hot_water_unit, laundry_unit, lr_agreement_unit, range_unit, frig_unit, baths_unit, bdrs_unit, rooms_unit, floor_loc_unit, deposit_u1, deposit_u2, deposit_u3, deposit_u4, rent_date_changed_u1, rent_date_changed_u2, rent_date_changed_u3, rent_date_changed_u4, rent_due_u1, rent_due_u2, rent_due_u3, rent_due_u4, show_u1, show_u2, show_u3, show_u4, style_u1, style_u2, style_u3, style_u4, tenant_u1, tenant_u2, tenant_u3, tenant_u4, tenant_phone_u1, tenant_phone_u2, tenant_phone_u3, tenant_phone_u4, heat_expense, ins_expense, management_expense, misc_expense, maint_expense, snow_expense, trash_expense, utilities_expense, ws_expense, current_use, easement, medium_photo"
'Response.write "<BR>" & Insert_flds
Set oConn = Server.CreateObject("ADODB.Connection")
mySQL2 = "Select count(*) NUMBER from mls where mod_date_time >= '" & last_com_date & "' and status in ('C','P') and web = 'Y'"
response.write "<br> mySQL2 = '" & mySQL2 & "'"
response.write "<BR>nhmlsdsn = " & nhmlsdsn
oConn.Open nhmlsdsn
set rsTemp2 = oConn.Execute(mySQL2)
rsCount = rsTemp2("NUMBER")
response.write "<BR>Number of records: " & rsCount
mySQL2 = "Select * from mlsvel where mod_date_time >= '" & last_com_date & "' and status in ('C','P') and web = 'Y'"
response.write "<br> mySQL2 = '" & mySQL2 & "'"
response.write "<BR>nhmlsdsn = " & nhmlsdsn
'oConn.Open nhmlsdsn
set rsTemp2 = oConn.Execute(mySQL2)
if rsTemp2.EOF Then
Response.Write "<BR>Error Occurred Executing Query...<BR>"
Response.Write "<BR>No Records Found!<BR>"
oConn.Close
Set oConn = Nothing
ObjectContext.SetAbort
Response.End
else
response.write "We are in the else part"
nof_Times = 0
Do While Not rsTemp2.EOF
response.write "<BR>This is number " & nof_Times & " Loop"
nof_Times = nof_Times + 1
response.write "<BR>This is number " & nof_Times & " Loop"
For i = 0 to 2 'rsCount
mySQL = "insert into mlsvel (" & Insert_flds & ") values ("
mySQL = mySQL & "'" & rsTemp2("id") & "',"
mySQL = mySQL & "'" & rsTemp2("type") & "',"
mySQL = mySQL & "'" & rsTemp2("mod_date_time") & "',"
' Shortened for brevity... There are about 274 fields total...
'medium_photo = rsTemp2("medium_photo")
'response.write (medium_photo)
mySQL = mySQL & "'" & rsTemp2("medium_photo") & "')"
'replace empty quotes with NULL
mySQL = Replace(mySQL,"''","NULL")
Response.write "mySQL = '" & mySQL & "'"
'oConn.Execute (mySQL)
Next
rsTemp2.MoveNext
Loop
ObjectContext.SetComplete
oConn.Close
Set oConn = Nothing
End If
End Sub
' CODE NOT FINISHED
%>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|