vbscript question

Results 1 to 4 of 4

Thread: vbscript question

  1. #1
    -a Guest

    Default vbscript question

    Is it possible to write a vbscript that checks to see if a function was successful or not? And if so, do a response.write?<BR>Example:<BR>Function doThis()<BR> rsRecordset1.Delete 1 <BR> rsRecordset1.Close <BR> Set rsRecordset1 = Nothing<BR> ADOConn.Close<BR> Set ADOConn = Nothing<BR> Response.Write "<BR>Done" <BR>End Function<BR><BR>I tried this..<BR><BR>If doThis() Then <BR>doThat<BR>End If<BR><BR>Function doThat()<BR>Response.write "You&#039;re doThis was successful!"<BR>End Function<BR><BR>But I know that is wrong.<BR>Please help.

  2. #2
    Kristin Hedge Guest

    Default Yes it is possible.

    I will pull an example from something I&#039;ve done and post it for you. Back in a flash

  3. #3
    Kristin Hedge Guest

    Default Ok....

    In this example the user is informed whether or not their record is saved in the db successfully.<BR>Keep in mind there is a bunch of includes (the connection code is also in an include) and redirected files, this is not contained in one page so not all code is shown in it&#039;s entirety, but you just need to follow the logic.<BR>Here&#039;s the Function to save to the database<BR>Function SaveEntry<BR> &#039; Save Entry to database<BR> DIM Return<BR> DIM Temp<BR> Temp = Request("NPA") + Request("NXX") + Request("Number")<BR> Return = OpenConnection(objectConn)<BR> If Return then<BR> Return = OpenWrite(objectSQL, objectConn, objectRS)<BR> If Return then<BR> objectRS.AddNew<BR> objectRS("DispoLast") = LEFT(Request("LastName"),35)<BR> objectRS("DispoFirst") = LEFT(Request("FirstName"),35)<BR> objectRS("DispoBTN") = LEFT(Temp,10)<BR> objectRS("DispoIssue") = LEFT(Request("ReasonCode"),5)<BR> objectRS("DispoRemarks") = Request("CallerRemarks")<BR> objectRS("DispoPBA") = LEFT(Request("PBA"),3)<BR> objectRS("DispoAgent") = Request.ServerVariables("AUTH_USER")<BR> objectRS("DispoTime") = Time<BR> objectRS("DispoDate") = Date<BR> objectRS("DispoIPAddr") = Request.ServerVariables("REMOTE_HOST")<BR> objectRS.Update<BR>&#039;Set your variable to true or false. You&#039;ll use this later on down...<BR> SaveEntry = True<BR> else<BR> SaveEntry = False<BR> End if<BR> Else<BR> SaveEntry = False<BR> End if<BR> CloseRecordset(objectRS)<BR> CloseConnection(objectConn)<BR>End Function <BR><BR>And then here is an example of how to display to the user if it is successful save to the db<BR>If SaveEntry then<BR> Response.redirect "Saved.asp"<BR>&#039;This page outputs a message saying it was successful<BR> else<BR> Response.Redirect "error.asp?ID=1"<BR> End if<BR>In the error.asp page there is a bunch of error messages that correspond to the id that is passed in the querystring.<BR>Hope this helps<BR>K.

  4. #4
    -a Guest

    Default RE: Ok....

    Thanks so much.<BR>I will sort through it and try it out. <BR>Thanks again for going out of your way to get this!

Posting Permissions

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