option explicit
' Port of MDAC ADO Conformance Test rsmovene.cls to vbscript and
' ScriptUnit
'
' Copyright 2006 - MySQL AB

' VBS doesn't have an "include" mechanism, and
' ScriptUnit doesn't like WSH files, so we're left with this
' hack for now...
Const testFile = "recordSetData.csv"
Dim fso: Set fso = CreateObject("Scripting.FileSystemObject")
Dim f: Set f = fso.OpenTextFile("../common/adovbs.inc", 1)
Dim s: s = f.ReadAll()
f.Close
Set f = Nothing
ExecuteGlobal s

Set f = fso.OpenTextFile("../common/mysql-common.inc", 1)   
s = f.ReadAll()   
ExecuteGlobal s
f.Close
Set f = Nothing	

Sub setup()
	Dim connection1, strSQL, data
	Set connection1 = CreateObject("ADODB.Connection")
	
	' get rid of test table if it's there
	strSQL = "DROP TABLE IF EXISTS ado_test"
	connection1.ConnectionString = connstr
	connection1.Open
	connection1.Execute(strSQL)

	' insert data into test table
	Set f = fso.OpenTextFile("../common/" & testFile,1)
	strSQL = f.readline
	connection1.Execute(strSQL)

	while NOT f.AtEndOfStream
		data = f.readline
		strSQL = "INSERT INTO ado_test VALUES (" & data & ")"
		connection1.Execute(strSQL)
	wend

	f.Close
	Set f = Nothing
	connection1.Close
	Set connection1 = Nothing
End Sub

Sub teardown()
	exit sub
	Dim connection1, strSQL
	Set connection1 = CreateObject("ADODB.Connection")
	
	' get rid of test table if it's there
	strSQL = "DROP TABLE ado_test"
	connection1.ConnectionString = connstr
	connection1.Open
	connection1.Execute(strSQL)
	connection1.Close
	Set connection1 = Nothing
End Sub

Sub Cleanup(conn, recset)
	recset.Close
	'Set recset.ActiveConnection = Nothing
	Set recset = Nothing
	conn.Close
	Set conn = Nothing
End Sub


Sub TestExecuteValidServer()
exit sub
	Dim connection1, recset1, strSQL
	Dim iTestRow, iTestCol, testVal, i, j
	Set connection1 = CreateObject("ADODB.Connection")
	Set recset1 = CreateObject("ADODB.RecordSet")
	
    connection1.ConnectionString = connstr
    connection1.CursorLocation = CInt(adUseServer) ' if used with adUseClient / adOpenStatic it works
    connection1.Open
    
	strSQL = "SELECT * FROM ado_test"
	
    ' open recordset
    recset1.Open strSQL, connection1, adOpenForwardOnly
	recset1.MoveFirst

	iTestRow = 94      ' there are 100 total records in this test table.  if this number is set to 94 or less then the test passes.

	' Jump to the test row
	recset1.Move (iTestRow)
	
	MsgBox "first field value from record: " & recset1.Fields(0).Value
	
	Call Cleanup (connection1, recset1)
End Sub

