Using the WITH statement in code

This is using the new WITH statement that comes with the latest scripting engine. One of the benefits of using this is you don't have to constantly refer to your object. If you have windows 2000/IIS 5.0, then you have the latest scripting engine.

Contributed by
Rating: 4 stars4 stars4 stars4 stars4 stars / 2
April 15, 2000
Rate this Article:
MEH MEH++


SEARCH ASP FREE
TOOLS YOU CAN USE

advertisement
Create an connection to the db.
set conn = server.createobject("adodb.connection")
conn.open "dsn=sqlsvr;database=pubs;uid=sa;pwd=;"

'Set local variables equals to the form data

strCompanyName = request.form("CompanyName")
strCompanyAddress1 = request.form("CompanyAddress1")
strCompanyAddress2 = request.form("CompanyAddress2")
strCompanyCity = request.form("CompanyCity")
strCompanyState =request.form("CompanyState")
strCompanyZip = request.form("CompanyZip")
strCompanyCountry =request.form("CompanyCountry")
strPrice = request.form("Price")
strCompanyID = request.form("CompanyID")

Create Command Object

set cmd1 = server.createobject("adodb.command")

'Start Your WITH statement
'Notice after that you can just put a period then the method your calling

With cmd1
    .activeconnection = strconn
    .commandtext = "sp_update"
    .CommandType = acCmdStoredProc
    .parameters.append .createparameter("@CompanyName", adVarChar, adParamInput, 150, strCompanyName)
    .parameters.append .createparameter("@CompanyAddress1", adVarChar, adParamInput, 255 , strCompanyAddress1)
    .parameters.append .createparameter("@CompanyAddress2", adVarChar, adParamInput, 255 , strCompanyAddress2)
    .parameters.append .createparameter("@CompanyCity", adVarChar, adParamInput, 150 , strCompanyCity)
    .parameters.append .createparameter("@CompanyState", adVarChar, adParamInput, 50 , strCompanyState)
    .parameters.append .createparameter("@CompanyZip", adVarChar, adParamInput, 50 , strCompanyZip)
    .parameters.append .createparameter("@CompanyCountry", adVarChar, adParamInput, 100 , strCompanyCountry)
    .parameters.append .createparameter("@Price", adVarChar, adParamInput, 50 , strPrice)
    .parameters.append .createparameter("@companyID", adInteger, adParamInput, 0 , strCompanyID)
    .execute lngRecs, , adExecuteNoRecords
'Once done put End WITH
End With
set cmd1 = nothing

blog comments powered by Disqus
ASP CODE ARTICLES

- ASP Forms
- ASP: The Beginning
- Getting Remote Files With ASP Continued
- Inbox and Outbox Manipulation in ASP
- Relational DropDownList Using VB.NET
- Ad Tracking URL Hits
- Use ViewState to display one record per page...
- Send Email using ASP.NET formatted in HTML
- ASP File Explorer
- ASP/XML Interview questions by Srivatsan Sri...
- Pressing RETURN won't submit the form
- This shows how you get the TEXT of a combo r...
- Group Data by Adrian Forbes
- Multiple checkbox select sample
- Multiple checkbox select with all values sam...

ASP Web Hosting ASP.Net Web Hosting Windows Web Hosting
 
 
 

ASP Free Forums 
 RSS  Tutorials RSS
 RSS  Forums RSS
 RSS  All Feeds
Site Map 
Request Media Kit
Write For Us Get Paid 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Privacy Policy 
Support 


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 5 - Follow our Sitemap
Most Popular Topics
All ASP.Net Tutorials