Wrox Programmer Forums
VBScript For questions and discussions related to VBScript.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VBScript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old December 29th, 2004, 11:25 AM
Registered User
Join Date: Dec 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Reading a table

I am trying to read a table (in SQL Server 2000), using VBScript, and creating a recordset in the process. I want the program to be able to read this recordset 1 line at a time. Thank you.
Reply With Quote
  #2 (permalink)  
Old December 29th, 2004, 02:04 PM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

What parts are you having problems with? Do you already have some code you can show us?

And in what environment are you building this? ASP, VBScript?

Reply With Quote
  #3 (permalink)  
Old December 30th, 2004, 09:05 AM
Friend of Wrox
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts

How about this...

Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3
strUserName = "username"
strPassword = "password"

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")

objConnection.Open "DSN=YourDSNNameHere;", strUserName, strPassword
objRecordset.CursorLocation = adUseClient
objRecordset.Open "SELECT * FROM tblYourTableNameHere" , _
objConnection, adOpenStatic, adLockOptimistic

Do While Not objRecordSet.EOF
   <Your statements>


This requires that you set up a system DSN first. I can give you the code to automate that, or you can do it manually.

Hope this helps.

Reply With Quote
  #4 (permalink)  
Old December 30th, 2004, 02:29 PM
Registered User
Join Date: Dec 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

Thank you for your help. I was able to get past the read of the SQL Server table by using a stored procedure but now when I use the method MoveNext, the program is telling me that it is expecting a function or variable. Here is the code I'm using:

blnRepMatch = True
For i = 1 To TotalReps
   Do While Not GetActiveReps.EOF
      If MyRepArray(i) <> GetActiveReps.MoveNext Then
         blnRepMatch = False
         Exit Do
      End If

GetActiveReps is the name of the stored procedure. Since Getactivereps is the name of the function, it is defined As a Recordset. All of this is done thru VBScript. I would expect, since GetActiveReps is defined as a Recordset that it would accept MoveNext, but it doesn't. Is this too confusing with the function name and the Recordset name being the same. Here is how GetActive Reps is defined:
         Private Function GetActiveReps() As ADODB.Recordset

If you see something I don't please let me know. Thanks, in advance, for your help.

Harry R. Egeth
Reply With Quote

Similar Threads
Thread Thread Starter Forum Replies Last Post
reading from a table cell? Atomsk Access VBA 2 September 28th, 2006 07:46 AM
reading table darkhalf Javascript 1 October 6th, 2005 11:37 AM
Reading a MS-Access table: PYee Javascript How-To 9 February 7th, 2005 08:12 AM
(oracle 8i)Alter Table <table> coalesce partition combo Oracle 3 October 13th, 2004 09:35 AM
size of table (type table is table of number) MikoMax Oracle 1 November 19th, 2003 03:11 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.