Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1009
  • Last Modified:

error '800a000d' Type mismatch: 'strRowArray' for Session Array

I am getting the following error in line 179 of Classic ASP code. It works in VB.net.
I am trying to asign a multi-dimention array to Session and vice versa.
Microsoft VBScript runtime error '800a000d' Type mismatch: 'strRowArray' for Session Array
If (strRowArray(i, j) = "" ) Then 'error:Line 179 Type mismatch: 'strRowArray'
This session array comes from Line 385
Session("strArrayDetail33") = strRowArray ' Line 385 strArrayDetail33
For clarity I am posting full code below:
Thanks in advance for any help given.
<% 
Sub BindData1()
currentPage = Request.QueryString("PageID")
if currentPage = 0 then
Response.Write("<div style='position:absolute;width:837px;height:150px;left:0px;top:250px;font-size:xx-small;overflow:auto;border:1px solid #722F90;' id='DIV999'>")
Response.Write("Page:" & currentPage & "#    ")
Dim objConn '//Connection object that the DataGrid will use
if Session("strConnection") = "" then
    
    else
    Dim strRowArray
    strRowArray = Session("strArrayDetail33") ' strRowArray(i, j)
    Dim oCounter : oCounter = 0
    Dim strCountRow
            For i = 0 To strCountRow '- 2
                For j = 0 To 88
                    If (strRowArray(i, j) = "" ) Then 'error:Line 179 Type mismatch: 'strRowArray' 

                    Else
                        oCounter = oCounter + 1
                        If oCounter = 7 Then
                            Response.Write("<br/>")
                            oCounter = 0
                        End If
                        If j = 0 Then
                            Response.Write("<a href='../scriptFrame/tempDefault" & (currentPage) & ".asp?db22=" & strRowArray(i, 0) & "&dt22=" & strRowArray(i, j) & "&intDetail22=" & intDetail22 & "&strD22=False" & "&PageID=" & (currentPage) & "' runat='server'>" & "<font color='#0000FF' size='2'>" & strRowArray(i, j) & "</font>" & "</a>&nbsp;&nbsp;&nbsp;&nbsp;")
                        Else
                            Response.Write("<a href='../scriptFrame/tempDefault" & (currentPage) & ".asp?db22=" & strRowArray(i, 0) & "&dt22=" & strRowArray(i, j) & "&intDetail22=" & intDetail22 & "&strD22=False" & "&PageID=" & (currentPage) & "' runat='server'>" & "<font color='#FF00FF' size='1'>" & strRowArray(i, j) & "</font>" & "</a>&nbsp;&nbsp;&nbsp;&nbsp;")
                        End If
                    End If
                Next 'j
            Next 'i
 End If   
 Response.Write("</div>")
end if   
End Sub
%>
<% 
Sub BindData3()
currentPage = Request.QueryString("PageID")
if currentPage = 0 then
Response.Write("<div style='position:absolute;width:837px;height:484px;left:0px;top:140px;font-size:xx-small;overflow:auto;border:1px solid #722F90;' id='DIV999'>")
Response.Write("Page:" & currentPage & "#    ")
Dim objConn, strQuery, dataRow, rowDatabase '//Connection object that the DataGrid will use
if Session("strConnection") = "" then
    
    else
    Response.Write("")
    Dim GetString 'As String = Nothing
    Dim GetString2 'As String = Nothing
    Dim TableLabelappTest
    Dim detailsLabelappTest
    Dim builder 'As New SqlConnectionStringBuilder(detailsLabelappTest)
    builder = Session("strConnection")
    Dim conn 'As New SqlConnection()
    Dim tblTables 'As DataTable = Nothing
    Dim odbconn 'As New SqlConnection()
    Dim strRowArray(100, 100) 'As String
    Dim strColumnArray(100, 400) 'As String
    'Dim localArray(100)
    Dim filterList 'As New List(Of String)()
    Dim dbitems 'As String = Nothing
    Dim tbitems 'As String = Nothing
    Dim caItem
    Dim strSQLServer   : strSQLServer = "Dinosaur1\sqlexpress"
    Dim strLogin       : strLogin     = "sa"
    Dim strPassword    : strPassword  = "H6web97!"
    Dim intDetail22    : intDetail22  = Session("strIntDetail22")
    Dim strRow         : strRow = 0 'As Integer = 0
    Dim strColumn      : strColumn = 0 'As Integer = 0
    Dim strCountRow    : strCountRow = 0 'As Integer = 0
    Dim strCountColumn : strCountColumn = 0 'As Integer = 0
    Dim oCounter       : oCounter = 0 'As Integer = 0
    Dim ErrorLabel     : ErrorLabel = ""
    Dim ConnStr, adoxConn, oServer, oDB, adodbConn, table, Item
    intDetail22 = intDetail22 + 1
    If intDetail22 > 10 Then
    intDetail22 = 10
    End If
    Set oServer = CreateObject("SQLDMO.SQLServer") 
    oServer.Name = strSQLServer 
    ' Check the server is alive 
    If oServer.Status <> 1 Then 
        Response.Write "Server " & strSQLServer & " is not running. Exiting." 
    End If 
    ' Connect to the SQL Server instance 
    oServer.LoginSecure = False 
    oServer.Connect strSQLServer, strLogin, strPassword 
    ' We're connected to the server let's iterate through the Databases Collection 
    For Each oDB in oServer.Databases 
        if oDB.Name = "master" or oDB.Name = "msdb" or oDB.Name = "model" or oDB.Name = "tempdb" then
        
        else
        strRowArray(strRow, strColumn) = oDB.Name
        'Response.Write  strRowArray(strRow, strColumn) & "#    " 
         strRow = strRow + 1
        end if
    Next 
    ' Disconnect from SQL Server 
    oServer.Disconnect 
    set oServer = nothing 
    
    strCountRow = strRow
            For i = 0 To strCountRow
                GetString2 = (builder & "; Initial Catalog=" & strRowArray(i, 0) & ";")
                ' Use this string if using SQL Server: 
                'ConnStr = "provider=SQLOLEDB;network=DBMSSOCN;" 
                'ConnStr = ConnStr & "uid=<uid>;pwd=<pwd>;server=" 
                'ConnStr = ConnStr & "<x.x.x.x>;database=" & dbname 
                ConnStr = Session("strConnection") & "Initial Catalog=" & strRowArray(i, 0) & ";"
                set adoxConn = CreateObject("ADOX.Catalog") 
                set adodbConn = CreateObject("ADODB.Connection") 
                adodbConn.open ConnStr 
                adoxConn.activeConnection = adodbConn 
                for each table in adoxConn.tables 
                    if table.type="TABLE" then 
                    strColumn = strColumn + 1
                    strColumnArray(i, strColumn) = table.name
                    'response.write   strColumnArray(i, strColumn) & "#    "
                end if 
                next 
                adodbConn.close: set adodbConn = nothing 
                set adoxConn = nothing  
                If strCountColumn <= strColumn Then
                    strCountColumn = strColumn
                End If
                strColumn = 0
            Next 'i
            'Response.Write("<br/><br/>Array:")
            'Response.Write("strCountRow:" & strCountRow & "#    ")
          
            For i = 0 To strCountRow '- 2
                strColumn = 0
                For j = 0 To 88
                    If (strColumnArray(i, j) = "") Then

                    Else
                        strColumn = strColumn + 1
                        strRowArray(i, strColumn) = strColumnArray(i, j)
                        'response.write   strRowArray(i, strColumn) & "#    "
                    End If
                Next 'j
                If strCountColumn <= strColumn Then
                    strCountColumn = strColumn
                End If
                strColumn = 0
            Next 'i
            
            oCounter = 0
            For i = 0 To strCountRow '- 2
                For j = 0 To 88
                    If (strRowArray(i, j) = "" ) Then

                    Else
                        oCounter = oCounter + 1
                        If oCounter = 7 Then
                            Response.Write("<br/>")
                            oCounter = 0
                        End If
                        If j = 0 Then
                            Response.Write("<a href='../scriptFrame/tempDefault" & (currentPage) & ".asp?db22=" & strRowArray(i, 0) & "&dt22=" & strRowArray(i, j) & "&intDetail22=" & intDetail22 & "&strD22=False" & "&PageID=" & (currentPage) & "' runat='server'>" & "<font color='#0000FF' size='2'>" & strRowArray(i, j) & "</font>" & "</a>&nbsp;&nbsp;&nbsp;&nbsp;")
                        Else
                            Response.Write("<a href='../scriptFrame/tempDefault" & (currentPage) & ".asp?db22=" & strRowArray(i, 0) & "&dt22=" & strRowArray(i, j) & "&intDetail22=" & intDetail22 & "&strD22=False" & "&PageID=" & (currentPage) & "' runat='server'>" & "<font color='#FF00FF' size='1'>" & strRowArray(i, j) & "</font>" & "</a>&nbsp;&nbsp;&nbsp;&nbsp;")
                        End If
                    End If
                Next 'j
            Next 'i
                            
Session("strArrayDetail33") = strRowArray ' Line 385 strArrayDetail33
 
    Dim jj : jj = 1
    Dim localArray
    Set fso = CreateObject("Scripting.FileSystemObject") 
    Set Session("fso") = fso 
    dim myArray(1) 
    myArray(0) = "foo" 
    myArray(1) = "bar" 
    Session("myArray") = myArray 
    Session("username") = "Splunge" 
    Session("password") = "BlatBar" 
    For Each Item In Session.Contents 
    if  item = "strArrayDetail33" then
        Session(item) = "strRowArray(i, j)"
        Response.Write  "<br/>    <b><u>" & item & " is an Session(array)</u></b>    "
    end if 
        If IsArray(Session(item)) Then 
            Response.Write  "    <b><u>" & item & " is an array</u></b>    " 
            ' if you know its structure, you can 
            ' loop through like this: 
            localArray = Session(item) 
            For i = 0 To Ubound(localArray) 
                Response.Write "<br>&nbsp;&nbsp;" & item 
                Response.Write "(" & i & ") = " & localArray(i) 
            Next 
        Elseif IsObject(Session(item)) Then 
            Response.Write  "    <b><u>" &  item & " is an object</u></b>    " 
            ' though we know we're not supposed to  
            ' store objects in the session, right? 
        Else 
            Response.Write "<b><u>" & item & "</u></b>" & " = " & Session(item) & "#    "
            if jj = 2 then
            Response.write("<br>")
            else
            
            end if 
            jj = jj + 1 
        End If 
        'Response.Write "<br>" 
    Next 
    set session("fso") = nothing 
    set fso = nothing 
    
 End If   
 Response.Write("</div>")
end if   
End Sub
%>

Open in new window

0
homeshopper
Asked:
homeshopper
  • 2
  • 2
1 Solution
 
homeshopperAuthor Commented:
For more clarity:
attached screen shot displaying BindData3() when button B3 is pressed
The error appears in BindData1() when button B1 is pressed.
Thanks in advance for any help given.
CaptureWiz098.jpg
0
 
Robert SchuttSoftware EngineerCommented:
Well, I can't really imagine that this is the problem, but at least it will get a conversation going.

In your 'debug code' it seems you're overwriting the very Session variable you want to use:
    For Each Item In Session.Contents 
    if  item = "strArrayDetail33" then
        Session(item) = "strRowArray(i, j)"

Open in new window

The way I read this, afterwards your Session("strArrayDetail33") is that literal string "strRowArray(i, j)", so no longer contains the actual 2-dimensional array.

To make it more clear what you're trying to achieve can you confirm that the second function is called first and the first function called later, from a different page perhaps? The post about the buttons didn't make it clearer because I don't know where those buttons are.

To take it one step further, I made 2 asp pages stripped down to test this functionality and it seems to work just fine:
capturepage1.asp:
<%
Dim strRowArray(100, 100)

Session("strArrayDetail33") = strRowArray

response.write "array assigned to session var..."
%>

Open in new window

page2.asp:
<%
Dim strRowArray
strRowArray = Session("strArrayDetail33")

If IsArray(strRowArray) Then
	Dim strCountRow, strCountCol
	strCountRow = UBound(strRowArray, 1)
	strCountCol = UBound(strRowArray, 2) ' or the other way around...
	response.write "array dimensions: " & strCountRow & " x " & strCountCol
Else
	response.write "no array"
End If
%>

Open in new window

0
 
homeshopperAuthor Commented:
Thank you for the help.
I have BindData3() in the header file, which is called first.
I had For the line         Each Item In Session.Contents
to display the contents of the session variables etc.
As per your suggestion, I took out this code.
You are right, it is causing the problem.
The last line of BindData3 is now        Session("strArrayDetail33") = strRowArray
Then    response.write "array assigned to session var..."
In the main part of the page BindData1() is called.
The following code as per your suggestion runs without errors:
<%
Dim strRowArray
    strRowArray = Session("strArrayDetail33") ' strRowArray(i, j)
    Dim oCounter : oCounter = 0

If IsArray(strRowArray) Then
	Dim strCountRow, strCountCol
	strCountRow = UBound(strRowArray, 1)
	strCountCol = UBound(strRowArray, 2) ' or the other way around...
	response.write "array dimensions: " & strCountRow & " x " & strCountCol
Else
	response.write "no array"
End If
%>

Open in new window

Then finally I added the following code to BindData1():
This now correctly displays the contents of the session variables etc created
in the header file BindData3()
With your suggestions, this will now allow me to use the contents of an array in any page.
As you said, the array can be created in one page and assigned to session.
Then in another page the contents of the array can be retreived from the session etc.
Thanks again for your help.
<%
Dim intDetail22
Response.Write("<br/>")
            For i = 0 To strCountRow 
                For j = 0 To strCountCol 
                    If (strRowArray(i, j) = "" ) Then 

                    Else
                        oCounter = oCounter + 1
                        If oCounter = 7 Then
                            Response.Write("<br/>")
                            oCounter = 0
                        End If
                        If j = 0 Then
                            Response.Write("<a href='../scriptFrame/tempDefault" & (currentPage) & ".asp?db22=" & strRowArray(i, 0) & "&dt22=" & strRowArray(i, j) & "&intDetail22=" & intDetail22 & "&strD22=False" & "&PageID=" & (currentPage) & "' runat='server'>" & "<font color='#0000FF' size='2'>" & strRowArray(i, j) & "</font>" & "</a>&nbsp;&nbsp;&nbsp;&nbsp;")
                        Else
                            Response.Write("<a href='../scriptFrame/tempDefault" & (currentPage) & ".asp?db22=" & strRowArray(i, 0) & "&dt22=" & strRowArray(i, j) & "&intDetail22=" & intDetail22 & "&strD22=False" & "&PageID=" & (currentPage) & "' runat='server'>" & "<font color='#FF00FF' size='1'>" & strRowArray(i, j) & "</font>" & "</a>&nbsp;&nbsp;&nbsp;&nbsp;")
                        End If
                    End If
                Next 'j
            Next 'i
 End If   
 Response.Write("</div>")
end if   
End Sub
%>

Open in new window

0
 
Robert SchuttSoftware EngineerCommented:
Great! Glad I could help.

Keep on shopping! ;-)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now