Results 1 to 4 of 4

Thread: help-urgent

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2000
    Posts
    29

    Exclamation

    This damn page is giving me a headache and i need some help to get the thing up and running so could some one please help me out. This is for a used car page and what i need it to do is add new/update/delete. i have included some debugging code but all that is telling me that it it sorat working but not 100%. Heres the deal I can add a new and modify and existing record but when i do that i get errors out of nowhere. addning new doesn't refresh the list to show the new listing (ERROR #1) and and the form disappears after you addnew/modify a record (ERROR #2). I will include the URL for you to get a visual www2.shaganappi.com/pages/newlayout.asp. PLEASE HELP ME I AM DYING!
    <%
    Dim dbData 'connection to database (ADODB.Connection)
    Dim rsData 'recordset to store cars in the dB
    Dim strSQL
    Dim rsOptions 'car options
    Dim CategoryID
    Dim VehicleID 'gets proper information related to selection
    Dim numincol '
    Dim i 'counter
    Dim rsCar
    Dim rsOption
    Dim a

    CategoryID = 0
    VehicleID = 0

    If Request.Form("CategoryID") <> vbNullString Then CategoryID = Request.Form("CategoryID")
    If Request.Form("VehicleList") <> vbNullString AND Request.Form("Section") = vbNullString Then VehicleID = CLng(Request.Form("VehicleList"))

    'Connection to Database
    Set dbData = Server.CreateObject("ADODB.Connection")
    dbData.Open Application("DSN")

    'Connection to Recordsets
    strSQL = " SELECT used_options.*, (SELECT CarID from used_car_options where OptionID = used_options.ID and CarID= " & VehicleID & ") as Exist"
    strSQL = strSQL & " from used_options"
    strSQL = strSQL & " Order by Description"
    Set rsOptions = Server.CreateObject("ADODB.Recordset")
    rsOptions.Open strSQL, dbData, 1, 3

    strSQL = "SELECT * From used_cars"
    strSQL = strSQL & " LEFT JOIN used_category ON used_cars.CategoryID = used_category.ID"
    strSQL = strSQL & " LEFT JOIN used_car_options ON used_cars.CarID = used_car_options.CarID"
    strSQL = strSQL & " LEFT JOIN used_options ON used_car_options.OptionID = used_options.ID"
    strSQL = strSQL & " WHERE used_cars.CarID = " & VehicleID

    if Request.Form("save")="save" then
    Response.Write "Save request received
    "
    if Request.Form("year")<>vbnullstring and Request.Form("make")<>vbnullstring and Request.Form("model")<>vbnullstring then
    Response.Write "Save request valid
    "
    set rsData=server.CreateObject("ADODB.Recordset")
    rsData.Open "SELECT * FROM used_cars WHERE CarID = " & Request.Form("VehicleList"),dbData,1,3
    if rsData.EOF then
    rsData.AddNew
    Response.Write "Adding new car...
    "
    Else
    Response.Write "Modifying existing car...
    "
    End If
    rsData.Fields("year")=clng(Request.Form("year"))
    rsData.Fields("make")=(Request.Form("make"))
    rsData.Fields("model")=(Request.Form("model"))
    rsData.Fields("color")=(Request.Form("color"))
    if Request.Form("Price")<>vbnullstring then rsData.Fields("Price")=ccur(Request.Form("Price"))
    if Request.Form("kms")<>vbnullstring then rsData.Fields("Kms")=clng(Request.Form("kms"))
    rsData.Update
    carID = rsData.Fields("CarID")
    Response.Write "rsData number " & carID & " updated...
    "
    rsData.Close
    set rsData=nothing
    end if
    elseif Request.Form("save")="delete" then
    if clng(Request.Form("VehicleList")) > 0 then
    dbData.Execute "DELETE FROM used_car_options WHERE CarID = " & Request.Form("VehicleID")
    dbData.Execute "DELETE FROM used_cars WHERE CarID = " & Request.Form("VehicleID")
    end if
    end if
    %>


    this code below produces error #2 on submit

    <font face="arial" size="2">Make</font> <input type="text" name="make" value="<%If CarID <> vbNullString then Response.Write rsData.Fields("Make")%>">

  2. #2
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    The problem with adding a new record may be as simple as a misspelled object reference on your recordset. When I try to add a record it says object required which could just be the recordset misspelled. The line the error occurs on is 351. Obviously you didn't post the entire page of code cuz there's only about 70 or so lines in your post so I can't tell which one is your problem, but check around line 351.

    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Dec 2000
    Posts
    29

    kinda sorta

    Monte96,
    the problem with the page adding new will add but wont show up in the list (???) problem 1... problem 2 if you want to edit a record the form gets screwed up with this line <font face="arial" size="2">Make</font>&nbsp;<input type="text" name="make" value="<%if VehicleID <>0 then Response.Write rsData.Fields("make")%>">.

    the form should populate either the list with the new value or the form the the values to edit but its not doing what it should. I know that it is saving the records by using the debugging code but why it is giving me object required error on that line (above) is beyond me

    rsData stores the cars in the db???...

    it just doesnt make sense to me whatsoever

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Dec 2000
    Posts
    29

    follow up

    if i change the line 237 to this instead

    <font face="arial" size="2">Make</font>&nbsp;<input type="text" name="make" value="<%if selected then Response.Write rsData.Fields("make")%>">

    using selected then the form doesnt give me the error but it doesn't populate?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width