![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | GetRows question... I am attempting to extract a column of data from SQL and store it into an array. When I attempt to display the array's contents, I don't see the results. Here is my code: 'Create the Recordset strSQL = "SELECT month FROM graph_LM_time_all " 'Open the Recordset objRS.Open strSQL, objConn 'Create the Array Dim myArray myArray = objRS.GetRows() 'Loop through the Array and write the results Dim i For i=0 to UBound(myArray) Response.Write myArray(i,0) & "<br />" Next I get no results returned. What am I missing? |
My System Specs![]() |
| | #2 (permalink) |
| | Re: GetRows question... You have to loop though the elements of the result set to get the data. |
My System Specs![]() |
| | #3 (permalink) |
| | Re: GetRows question... "Ken D." <KenD@xxxxxx> wrote in message news:5BC23987-1C83-4E94-ACA4-0470262F7B38@xxxxxx Quote: >I am attempting to extract a column of data from SQL and store it into an > array. When I attempt to display the array's contents, I don't see the > results. Here is my code: > > 'Create the Recordset > strSQL = "SELECT month FROM graph_LM_time_all " > > 'Open the Recordset > objRS.Open strSQL, objConn > > 'Create the Array > Dim myArray > myArray = objRS.GetRows() response.write "[" & ubound(myArray) & "]" Quote: > 'Loop through the Array and write the results > Dim i > For i=0 to UBound(myArray) > Response.Write myArray(i,0) & "<br />" > Next > > I get no results returned. What am I missing? /Al |
My System Specs![]() |
| | #4 (permalink) |
| | Re: GetRows question... Ken D. schrieb: Quote: > I am attempting to extract a column of data from SQL and store it into an > array. When I attempt to display the array's contents, I don't see the > results. Here is my code: > > 'Create the Recordset > strSQL = "SELECT month FROM graph_LM_time_all " > > 'Open the Recordset > objRS.Open strSQL, objConn > > 'Create the Array > Dim myArray > myArray = objRS.GetRows() > > 'Loop through the Array and write the results > Dim i > For i=0 to UBound(myArray) > Response.Write myArray(i,0) & "<br />" > Next > > I get no results returned. What am I missing? second dimension rows. See: Dim oFS : Set oFS = CreateObject( "Scripting.FileSystemObject" ) Dim sTDir : sTDir = oFS.GetAbsolutePathName( ".\adotext" ) Dim sTable : sTable = "jmastrianb" Dim sCS : sCS = Join( Array( _ "Provider=MSDASQL.1" _ , "Driver={Microsoft Text Driver (*.txt; *.csv)}" _ , "DBQ=" & sTDir _ ), ";" ) Dim oCN : Set oCN = CreateObject( "ADODB.Connection" ) oCN.Open sCS Dim sSQL : sSQL = "SELECT * FROM [" & sTable & ".txt]" Dim oRS : Set oRS = oCN.Execute( sSQL ) Dim aData : aData = oRS.GetRows() WScript.Echo "cols:", UBound( aData, 1 ) + 1 WScript.Echo "rows:", UBound( aData, 2 ) + 1 Dim nRow For nRow = 0 To UBound( aData, 2 ) Dim nCol For nCol = 0 To UBound( aData, 1 ) WScript.Echo nRow, nCol, aData( nCol, nRow ) Next WScript.Echo Next oRS.Close oCN.Close output: === demoGetRows: demo .GetRows() ======= cols: 3 rows: 4 0 0 123 0 1 7654321 0 2 123456789 1 0 12 1 1 Joe 1 2 Bellmonts 2 0 1 2 1 A 2 2 Short 3 0 33 3 1 Deborah 3 2 Whereever === demoGetRows: 0 done (00:00:01) ===== |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| escape character question - hopefully an easy question | PowerShell | |||
| question is | Vista mail | |||
| Question | Vista mail | |||
| vista genral question and ultimate question | Vista General | |||
| Dual boot system question and family deal discount question | Vista General | |||