solve this a i'll give you $1,000

Results 1 to 3 of 3

Thread: solve this a i'll give you $1,000

  1. #1
    adrian Guest

    Default solve this a i'll give you $1,000

    Not!!<BR><BR>anyway i&#039;m trying to make a script that allows data to be inserted into a database, this is what is have so far:<BR><BR>&#060;%<BR>Dim objConn, objRS, strConn, strOut<BR>Dim strCN, strPh, lngid<BR><BR>On Error Resume Next<BR>&#039; Create and open connection object.<BR>sPath = Server.MapPath("/db/car.mdb")<BR>strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sPath<BR>Set objConn = Server.CreateObject("ADODB.Connection")<BR>objConn .Open strConn<BR><BR>Set objRS = Server.CreateObject("ADODB.Recordset")<BR><BR>&#03 9; Listing 15.3 Reading All Data from the car Table<BR>If (Request.ServerVariables("CONTENT_LENGTH") &#062; 0) Then<BR> strCN = Trim(Request.Form("car"))<BR> strCN = Left(strCN,40)<BR> If Len(strCN) &#062; 0 Then<BR> objRS.CursorLocation = adUseServer<BR> objRS.CursorType = adOpenKeyset<BR> objRS.LockType = adLockOptimistic<BR> objRS.Open "car", objConn, , , adCmdTable<BR> objRS.AddNew<BR> objRS("car") = strCN<BR> strPh = Trim(Request.Form("phone"))<BR> strPh = Left(strPh,24)<BR> If Len(strPh) &#062; 0 Then<BR> objRS("phone") = strPh<BR> End If<BR> objRS.Update<BR> lngid = objRS("id")<BR> Response.Write "Your new record has car ID "<BR> Response.Write lngid & ".<BR><BR>"<BR> objRS.Close<BR> Else<BR> Response.Write "Please supply a Car Name!<BR><BR>"<BR> End If<BR>End If<BR>%&#062;<BR><BR><BR>Please help, some of the script has been cut from other sources<BR>I going insane trying to fix it.<BR><BR>HELP

  2. #2
    Join Date
    Dec 1969

    Default RE: solve this a i'll give you $1,000

    check if ID is not a reserved word, change the name and see if it works, also once u update the table with<BR>"objRS.update", how are u getting the "id" in objRS("id"), havent worked a lot with Access but dont u have to write a query to get that "ID" field from the table?

  3. #3
    Join Date
    Dec 1969

    Default RE: solve this a i'll give you $1,000

    There are several problems in that code. Try the FAQ&#039;s at the top of the page and build it again. It will be faster and you&#039;ll learn how and why things work. You&#039;ll never get the ID of the record the way you are trying it and there is an FAQ just for that.

Posting Permissions

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