Important alert: (current site time 7/15/2013 11:27:23 PM EDT)
 

VB icon

a template to create a VBScript Class

Email
Submitted on: 11/3/2003 11:43:09 AM
By: moppy 
Level: Intermediate
User Rating: Unrated
Compatibility: ASP (Active Server Pages)
Views: 14790
 
     use this as a template to create a VB Script class file for accessing data from recordsets.
 
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 languages 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: a template to create a VBScript Class
' Description:use this as a template to create a VB Script class file for accessing data from recordsets.
' By: moppy
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=8606&lngWId=4'for details.'**************************************

<%
'	Template Class
'
'---------------------------------------------------------------------------------------->
'	Author					Date				History				Version
'	Richard Slade			03/11/2003			Created				V1.0	
'- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >
Class clsClassname
	'//------ private variable declarations--------------------->
	private cmdSpeaker, rsSpeaker
	private m_connection
	'//------ class start--------------------------------------->
	private sub Class_Initialize()
		setLocale("2057")
		With Server
			set cmd = .createobject("ADODB.command")
			set rs = .createobject("ADODB.recordset")
		End With
	end sub
	'//------ class termination--------------------------------->
	private sub Class_Terminate()
		if cmd.state = adStateOpen then
			cmd.close()
		end if
		set cmd = nothing
		set rs = nothing		
	end sub
	'//-------all generic stuff, nothing to see here------------>
	private sub subReuseCommandObj()
		set cmd = nothing
		Set cmd = Server.CreateObject("ADODB.Command")
	end sub
	'//-------move next
	public sub moveNext()
		rs.moveNext()
	end sub
	'//------bof eof
	public property get eof()
		eof = rs.eof
	end property
	'//------get SQL col
	private function getCol(prmFieldName)
		if rs.eof then
			getCol = "no data"
		else
			getCol = rs(prmFieldName)
		end if
	end function
	'//------general properties----------------------------------->
	public property let connection(prmConnection)
		m_connection = prmConnection
	end property
	'//-------recordset properties-------------------------------->
	public property get rsSpeaker_companyName
		rsSpeaker_companyName = getCol("companyName")
	end property
	'//-------methods----------------------------------------->
	public sub subName()
		subReuseCommandObj()
		With cmd
			.ActiveConnection = m_connection
			.CommandType = adCmdStoredProc
			.CommandText = "spName"
			.Parameters.Append cmd.CreateParameter("@param_Value", adVarchar, adParamInput,50 , param)
		End With
		Set rs = cmd.Execute
	end sub
End Class
%>


Other 5 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.