wrote,thise,codeWhile,working,project,realize
Quick Search for: in language:   
wrote,thise,codeWhile,working,project,realize
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
ASP/ VbScript Stats

 Code: 101,137 lines
 Jobs: 277 postings

 

You are in:

 
Login


 

 

Latest Code Ticker for ASP/ VbScript
Click here to see a screenshot of this code!Online Database Editor
By Andy T. on 3/18

(Screen Shot)

What is going on on PSCode.com?!?!
By Timothy Beutels on 3/18


Write out time for different time zones [8:24:18 PM]
By snowboardr on 3/18


Click here to see a screenshot of this code!Picture Upload/View
By John Overton on 3/17

(Screen Shot)

Variables in #INCLUDE FILE
By Drew Gulbransen on 3/17


Unbreakable Password Protection
By Rahul Mahajan on 3/17


Click here to see a screenshot of this code!Instant Connect
By John Overton on 3/16

(Screen Shot)

Click here to see a screenshot of this code!Folder Interface
By Lewis Moten on 3/16

(Screen Shot)

Click here to see a screenshot of this code!ASP XML Calendar
By John Overton on 3/15

(Screen Shot)

Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!





Affiliate Sites



 
 

 
 

   

Universal Database Updater

Print
Email
 
VB icon
Submitted on: 2/26/2002 11:53:35 AM
By: Sam Moses  
Level: Intermediate
User Rating: By 2 Users
Compatibility:ASP (Active Server Pages)

Users have accessed this code 1029 times.
 

(About the author)
 
     Why I wrote thise code: While working on a project, I realized that I was writing too many update statements. Not that it's hard, but hand coding update statements can feel like pulling teeth if you are working with large applications where you do a lot of updating. So why not create a dynamic update statement that saves time, and effort, and only needs to be written once? Okay, I admit it, I can be lazy sometimes. But this one is actually useful. This code takes values from a querystring and uses them to update two fields within a database record. It can be used for any table in any access database.
 
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!

    '**************************************
    ' for :Universal Database Updater
    '**************************************
    mention flying monkeys.
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for langauges that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

    '**************************************
    ' Name: Universal Database Updater
    ' Description:Why I wrote thise code:
    While working on a project, I realized that I was writing too many update statements. Not that it's hard, but hand coding update statements can feel like pulling teeth if you are working With large applications where you Do a lot of updating. So why not create a dynamic update statement that saves time, and effort, and only needs to be written once? Okay, I admit it, I can be lazy sometimes. But this one is actually useful.
    This code takes values from a querystring and uses them To update two fields within a database record. It can be used For any table in any access database.
    ' By: Sam Moses
    '
    ' Inputs:'The only hard coded value is t
    '     he database path. 
    'This can be changed.
    'Query String Values:
    'table: Your table name
    'field1: Your first field name
    'field1_value: the value you want to put
    '     into your field
    'field2: Your second field name
    'field2_value: The value you want to put
    '     into your second field.
    'where_value: the name of your primary k
    '     ey field
    'primarykey: the value in your primary k
    '     ey field
    'diagnostic: if diagnostic=test then it 
    '     will tell 
    'you what has been updated
    'reset: If you are not using it in diagn
    '     ostic 
    'mode, your reset should be the URL you 
    '     want to 
    'redirect to.
    '
    ' Assumes:I'm guessing most intermediate
    '     programmers will be able to read this. I
    '     t could be a big time saver if used prop
    '     erly.
    '
    ' Side Effects:'Jumping for joy.
    '
    'This code is copyrighted and has    ' limited warranties.Please see http://w
    '     ww.Planet-Source-Code.com/xq/ASP/txtCode
    '     Id.7269/lngWId.4/qx/vb/scripts/ShowCode.
    '     htm    'for details.    '**************************************
    
    <%
    DataConnection = "Driver={Microsoft Access Driver (*.mdb)};Dbq=c:\database\data.mdb;"
    if request.querystring("state")="update" Then
    Set Command1 = Server.CreateObject("ADODB.Command")
    Command1.ActiveConnection = DataConnection
    Command1.CommandText = "UPDATE "&request.querystring;("table")&" Set "&request.querystring;("field1")&"='"&request.querystring;("field1_value")&"',"&request.querystring;("field2")&"='"&request.querystring;("field2_value")&"' WHERE "&request.querystring;("where_value")&"="&request.querystring;("primarykey")&""
    Command1.CommandType = 1
    Command1.CommandTimeout = 0
    Command1.Prepared = True
    Command1.Execute()
    if request.querystring("diagnostic") = "test" Then 
    Response.Write "the table <B>"&request.querystring;("table")&" </B> has had the following values updated<BR>"
    Response.Write "<B>"&request.querystring;("field1")&" </B>has been updated To use <B>"&request.querystring;("field1_value")&"</B> as it's value <BR>"
    Response.Write "<B>"&request.querystring;("field2")&" </B> has been updated To use <B>"&request.querystring;("field2_value")&" </B>as it's value <BR>"
    Response.Write "Your primary key is <B>"&request.querystring;("where_value")&" </B> and it has updated where the value of that key is Set To <B>"&request.querystring;("primarykey")&"</B><P>"
    Response.Write "This update is based on the values In the querystring. To change these values, or update a different Set of fields or tables, Then just change the values in the address bar above."
    Response.Write "</P><P><B>Universal Querystring Updater</B><BR>By <A href='http://sammoses.com'>Sam Moses</A> (c) 2002</P>"
    End if
    if request.querystring("diagnostic")="" Then response.redirect "" &request.querystring;("reset")&""
    End if
    %>


Other 9 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Intermediate category)?
(The codewith your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
2/27/2002 6:54:05 AM:Ken Hardwick
Sam,
Another great submission, keep up 
the great work. Haven't seen you 
hanging out around CodeCharge any 
lately !
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/27/2002 11:21:17 PM:snowboardr
Good job sam on this, I was just about 
to write code to update my site user's 
profile...but I think this may do. 
5*
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | ASP/ VbScript Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.