NeedHelpProgrammer
Programmer
I have looked over my global.asp and my add.asp.
I keep getting this same type mismatch error.
Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'UBound'
/aspApp/add.asp, line 5
This is the area of code that I keep fumbling on.
Depts = Application("Depts")
For i = 0 to UBound(Depts,2)
If cStr(Depts(0,i)) = Request.Form("DepartmentID") Then
strDept = Depts(1,i)
End IF
Isn't UBound an integer because it determines the highest possible subscript for the second dimension of the Depts array? Thus i = 0 to UBound(Dept,2) the same datatype?
I would so appreciate some ideas.
Thank you
-----------------------------------------------
Here is the whole code of global.asa
<SCRIPT LANGUAGE="VBS" RUNAT="Server">
Sub Application_OnStart()
Dim Depts()
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open("employee")
sql = "SELECT ID, Department FROM Departments"
Set rsRecords = Conn.Execute(sql)
i = 0
do while not rsRecords.EOF
Redim Preserve Depts(2,i)
Depts(0, i) = rsRecords("ID")
Depts(1, i) = rsRecords("Department")
i = i + 1
rsRecords.MoveNext
loop
Application("Depts") = Depts
rsRecords.Close
Conn.Close
Set Conn = Nothing
End Sub
Sub Application_OnEnd()
Application("Message") = "Done!"
End Sub
Sub Session_OnStart()
End Sub
Sub Session_OnEnd()
End Sub
</SCRIPT>
-------------------------------------------
here is the whole section of that code in add.asp
<%
Depts = Application("Depts")
For i = 0 to UBound(Depts,2)
If cStr(Depts(0,i)) = Request.Form("DepartmentID") Then
strDept = Depts(1,i)
End IF
Next
On Error Resume Next
Dim Conn, name, dept, homePhone, ext, sql
If Request.Form("Name") <> "" Then
name = Replace(Request.Form("Name"), "'", "'")
dept = Request.Form("DepartmentID")
homePhone = Request.Form("Home_Phone")
ext = Request.Form("Extension")
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open("employee")
sql = "INSERT INTO employee (Name, DepartmentID, Home_Phone, Extension) VALUES ("
sql = sql & "'" & name & "','" & dept & "','" & homePhone & "','"
sql = sql & ext & "')"
Conn.Execute(sql)
'Debug
'Response.Write(sql)
%>
I keep getting this same type mismatch error.
Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'UBound'
/aspApp/add.asp, line 5
This is the area of code that I keep fumbling on.
Depts = Application("Depts")
For i = 0 to UBound(Depts,2)
If cStr(Depts(0,i)) = Request.Form("DepartmentID") Then
strDept = Depts(1,i)
End IF
Isn't UBound an integer because it determines the highest possible subscript for the second dimension of the Depts array? Thus i = 0 to UBound(Dept,2) the same datatype?
I would so appreciate some ideas.
Thank you
-----------------------------------------------
Here is the whole code of global.asa
<SCRIPT LANGUAGE="VBS" RUNAT="Server">
Sub Application_OnStart()
Dim Depts()
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open("employee")
sql = "SELECT ID, Department FROM Departments"
Set rsRecords = Conn.Execute(sql)
i = 0
do while not rsRecords.EOF
Redim Preserve Depts(2,i)
Depts(0, i) = rsRecords("ID")
Depts(1, i) = rsRecords("Department")
i = i + 1
rsRecords.MoveNext
loop
Application("Depts") = Depts
rsRecords.Close
Conn.Close
Set Conn = Nothing
End Sub
Sub Application_OnEnd()
Application("Message") = "Done!"
End Sub
Sub Session_OnStart()
End Sub
Sub Session_OnEnd()
End Sub
</SCRIPT>
-------------------------------------------
here is the whole section of that code in add.asp
<%
Depts = Application("Depts")
For i = 0 to UBound(Depts,2)
If cStr(Depts(0,i)) = Request.Form("DepartmentID") Then
strDept = Depts(1,i)
End IF
Next
On Error Resume Next
Dim Conn, name, dept, homePhone, ext, sql
If Request.Form("Name") <> "" Then
name = Replace(Request.Form("Name"), "'", "'")
dept = Request.Form("DepartmentID")
homePhone = Request.Form("Home_Phone")
ext = Request.Form("Extension")
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open("employee")
sql = "INSERT INTO employee (Name, DepartmentID, Home_Phone, Extension) VALUES ("
sql = sql & "'" & name & "','" & dept & "','" & homePhone & "','"
sql = sql & ext & "')"
Conn.Execute(sql)
'Debug
'Response.Write(sql)
%>