473,382 Members | 1,717 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Type mismatch - using arrays and functions

Help. Below is my code. Getting Type mismatch error on
the noted line. I'm trying to send an array (aryNewD)
with 4 columns and x rows to a function to save all the
array info into a SQL Server table via a stored
procedure. Keep getting this error. Any suggestions?

Code:
'ASP:

if blnNewD then
dim blnWrite
if fDisasterDescription_Write2(aryNewD) = 1
then 'ERROR MESSAGE POINTS TO THIS LINE
blnWrite = True
else
blnWrite = False
end if
if not blnWrite then blnValid = False
if blnValid = False then
response.write "An error has occured."
response.end
end if
end if

'---------------------------------------------------------
-----------------------------
'Function:

function fDisasterDescription_Write2(aryNewD)
dim conDisasterWaste, cmdDisasterWaste,
blnCriticalError
dim param1, param2, param3, param4, param5
dim my_adCmdStoredProc, my_adChar, my_adInteger,
my_adParamInput
dim my_adSmallInt, my_adVarChar, my_adDate
dim strTypeID, strDescription, strDate, intDisasterID

my_adCmdStoredProc = &H0004
my_adChar = 129
my_adInteger = 3
my_adParamInput = &H0001
my_adSmallInt = 2
my_advarchar = 200
my_adDate = 7

'Set the Connection Object

set conDisasterWaste = server.createobject
("ADODB.Connection")

conDisasterWaste.Open "database", "username", "password"

'Run stored procedure

set cmdDisasterWaste = server.CreateObject
("ADODB.Command")

set cmdDisasterWaste.ActiveConnection =
conDisasterWaste
cmdDisasterWaste.CommandType = my_adCmdStoredProc
cmdDisasterWaste.CommandText
= "tf_insert_DisasterDescription"

set param1 = cmdDisasterWaste.CreateParameter
("@idLandfill", my_adChar, my_adParamInput, 12)
set param2 = cmdDisasterWaste.CreateParameter
("@typeID", my_adSmallint, my_adParamInput)
set param3 = cmdDisasterWaste.CreateParameter
("@description", my_advarchar, my_adParamInput, 1000)
set param4 = cmdDisasterWaste.CreateParameter("@date",
my_adDate, my_adParamInput)
set param5 = cmdDisasterWaste.CreateParameter
("@disasterid", my_adinteger, my_adParamInput)

cmdDisasterWaste.Parameters.Append(param1)
cmdDisasterWaste.Parameters.Append(param2)
cmdDisasterWaste.Parameters.Append(param3)
cmdDisasterWaste.Parameters.Append(param4)
cmdDisasterWaste.Parameters.Append(param5)

cmdDisasterWaste.Parameters("@idlandfill") = Session
("idlandfill")

For i = 0 to ubound(aryNewD, 2)
strTypeID = aryNewD(1, i)
strDescription = aryNewD(3, i)
strDate = aryNewD(2, i)
intDisasterID = aryNewD(0, i)

cmdDisasterWaste.Parameters("@typeID") = strTypeID
cmdDisasterWaste.Parameters("@description") =
strDescription
cmdDisasterWaste.Parameters("@date") = strDate
cmdDisasterWaste.Parameters("@disasterid") =
intDisasterID

cmdDisasterWaste.execute
Next

If Err.number = 0 then
fDisasterDescription_Write2 = 1
Else
fDisasterDescription_Write2 = 2
Response.Write(err.description & "<br>")
end if

set cmdDisasterWaste.ActiveConnection = Nothing
set cmdDisasterWaste = Nothing

conDisasterWaste.Close
set conDisasterWaste = Nothing
end function

THANK YOU!

Jul 19 '05 #1
4 10676
You should use the IsArray function to test that it is actually an array,
before calling the function, or in the first part of the function.

"Laura" <Pl**********@to.the.newsgroup> wrote in message
news:85****************************@phx.gbl...
Help. Below is my code. Getting Type mismatch error on
the noted line. I'm trying to send an array (aryNewD)
with 4 columns and x rows to a function to save all the
array info into a SQL Server table via a stored
procedure. Keep getting this error. Any suggestions?

Code:
'ASP:

if blnNewD then
dim blnWrite
if fDisasterDescription_Write2(aryNewD) = 1
then 'ERROR MESSAGE POINTS TO THIS LINE
blnWrite = True
else
blnWrite = False
end if
if not blnWrite then blnValid = False
if blnValid = False then
response.write "An error has occured."
response.end
end if
end if

'---------------------------------------------------------
-----------------------------
'Function:

function fDisasterDescription_Write2(aryNewD)
dim conDisasterWaste, cmdDisasterWaste,
blnCriticalError
dim param1, param2, param3, param4, param5
dim my_adCmdStoredProc, my_adChar, my_adInteger,
my_adParamInput
dim my_adSmallInt, my_adVarChar, my_adDate
dim strTypeID, strDescription, strDate, intDisasterID

my_adCmdStoredProc = &H0004
my_adChar = 129
my_adInteger = 3
my_adParamInput = &H0001
my_adSmallInt = 2
my_advarchar = 200
my_adDate = 7

'Set the Connection Object

set conDisasterWaste = server.createobject
("ADODB.Connection")

conDisasterWaste.Open "database", "username", "password"

'Run stored procedure

set cmdDisasterWaste = server.CreateObject
("ADODB.Command")

set cmdDisasterWaste.ActiveConnection =
conDisasterWaste
cmdDisasterWaste.CommandType = my_adCmdStoredProc
cmdDisasterWaste.CommandText
= "tf_insert_DisasterDescription"

set param1 = cmdDisasterWaste.CreateParameter
("@idLandfill", my_adChar, my_adParamInput, 12)
set param2 = cmdDisasterWaste.CreateParameter
("@typeID", my_adSmallint, my_adParamInput)
set param3 = cmdDisasterWaste.CreateParameter
("@description", my_advarchar, my_adParamInput, 1000)
set param4 = cmdDisasterWaste.CreateParameter("@date",
my_adDate, my_adParamInput)
set param5 = cmdDisasterWaste.CreateParameter
("@disasterid", my_adinteger, my_adParamInput)

cmdDisasterWaste.Parameters.Append(param1)
cmdDisasterWaste.Parameters.Append(param2)
cmdDisasterWaste.Parameters.Append(param3)
cmdDisasterWaste.Parameters.Append(param4)
cmdDisasterWaste.Parameters.Append(param5)

cmdDisasterWaste.Parameters("@idlandfill") = Session
("idlandfill")

For i = 0 to ubound(aryNewD, 2)
strTypeID = aryNewD(1, i)
strDescription = aryNewD(3, i)
strDate = aryNewD(2, i)
intDisasterID = aryNewD(0, i)

cmdDisasterWaste.Parameters("@typeID") = strTypeID
cmdDisasterWaste.Parameters("@description") =
strDescription
cmdDisasterWaste.Parameters("@date") = strDate
cmdDisasterWaste.Parameters("@disasterid") =
intDisasterID

cmdDisasterWaste.execute
Next

If Err.number = 0 then
fDisasterDescription_Write2 = 1
Else
fDisasterDescription_Write2 = 2
Response.Write(err.description & "<br>")
end if

set cmdDisasterWaste.ActiveConnection = Nothing
set cmdDisasterWaste = Nothing

conDisasterWaste.Close
set conDisasterWaste = Nothing
end function

THANK YOU!

Jul 19 '05 #2
Even if I change the function to get rid of the database
crap and simply be the following:

function fDisasterDescription_write3(aryNewD)

dim strTypeID, strDescription, strDate, intDisasterID

fDisasterDescription_write3 = 2

For i = 0 to ubound(aryNewD, 2)
strTypeID = aryNewD(1, i)
strDescription = aryNewD(3, i)
strDate = aryNewD(2, i)
intDisasterID = aryNewD(0, i)

response.write strTypeID & ", " & strDescription
& ", " & strDate & ", " & intDisasterID & "<br>"
Next

if err.number > 0 then
fDisasterDescription_Write3 = 2
else
fDisasterDescription_Write3 = 1
end if

end function
I still have the same type mismatch error. Help?
-----Original Message-----
Checked - it is an array, but still no go with the
function. Other ideas?
-----Original Message-----
You should use the IsArray function to test that it isactually an array,
before calling the function, or in the first part of thefunction.

"Laura" <Pl**********@to.the.newsgroup> wrote in message
news:85****************************@phx.gbl...
Help. Below is my code. Getting Type mismatch error
on the noted line. I'm trying to send an array (aryNewD)
with 4 columns and x rows to a function to save all the array info into a SQL Server table via a stored
procedure. Keep getting this error. Any suggestions?

Code:
'ASP:

if blnNewD then
dim blnWrite
if fDisasterDescription_Write2(aryNewD) = 1
then 'ERROR MESSAGE POINTS TO THIS LINE
blnWrite = True
else
blnWrite = False
end if
if not blnWrite then blnValid = False
if blnValid = False then
response.write "An error has occured."
response.end
end if
end if

'----------------------------------------------------- ----
-----------------------------
'Function:

function fDisasterDescription_Write2(aryNewD)
dim conDisasterWaste, cmdDisasterWaste,
blnCriticalError
dim param1, param2, param3, param4, param5
dim my_adCmdStoredProc, my_adChar, my_adInteger,
my_adParamInput
dim my_adSmallInt, my_adVarChar, my_adDate
dim strTypeID, strDescription, strDate,intDisasterID
my_adCmdStoredProc = &H0004
my_adChar = 129
my_adInteger = 3
my_adParamInput = &H0001
my_adSmallInt = 2
my_advarchar = 200
my_adDate = 7

'Set the Connection Object

set conDisasterWaste = server.createobject
("ADODB.Connection")

conDisasterWaste.Open "database", "username", "password"
'Run stored procedure

set cmdDisasterWaste = server.CreateObject
("ADODB.Command")

set cmdDisasterWaste.ActiveConnection =
conDisasterWaste
cmdDisasterWaste.CommandType = my_adCmdStoredProc
cmdDisasterWaste.CommandText
= "tf_insert_DisasterDescription"

set param1 = cmdDisasterWaste.CreateParameter
("@idLandfill", my_adChar, my_adParamInput, 12)
set param2 = cmdDisasterWaste.CreateParameter
("@typeID", my_adSmallint, my_adParamInput)
set param3 = cmdDisasterWaste.CreateParameter
("@description", my_advarchar, my_adParamInput, 1000)
set param4 = cmdDisasterWaste.CreateParameter("@date", my_adDate, my_adParamInput)
set param5 = cmdDisasterWaste.CreateParameter
("@disasterid", my_adinteger, my_adParamInput)

cmdDisasterWaste.Parameters.Append(param1)
cmdDisasterWaste.Parameters.Append(param2)
cmdDisasterWaste.Parameters.Append(param3)
cmdDisasterWaste.Parameters.Append(param4)
cmdDisasterWaste.Parameters.Append(param5)

cmdDisasterWaste.Parameters("@idlandfill") =
Session ("idlandfill")

For i = 0 to ubound(aryNewD, 2)
strTypeID = aryNewD(1, i)
strDescription = aryNewD(3, i)
strDate = aryNewD(2, i)
intDisasterID = aryNewD(0, i)

cmdDisasterWaste.Parameters("@typeID") =

strTypeID cmdDisasterWaste.Parameters("@description") =
strDescription
cmdDisasterWaste.Parameters("@date") = strDate
cmdDisasterWaste.Parameters("@disasterid") =
intDisasterID

cmdDisasterWaste.execute
Next

If Err.number = 0 then
fDisasterDescription_Write2 = 1
Else
fDisasterDescription_Write2 = 2
Response.Write(err.description & "<br>")
end if

set cmdDisasterWaste.ActiveConnection = Nothing
set cmdDisasterWaste = Nothing

conDisasterWaste.Close
set conDisasterWaste = Nothing
end function

THANK YOU!

.

.

Jul 19 '05 #3
What happens if you set the function result to a variable

dim code

code = fDisasterDescription_Write2(aryNewD)
Response.Write code

--
Mark Schupp
--
Head of Development
Integrity eLearning
Online Learning Solutions Provider
ms*****@ielearning.com
http://www.ielearning.com
714.637.9480 x17
"Laura" <pl**********@to.the.newsgroup> wrote in message
news:06****************************@phx.gbl...
Even if I change the function to get rid of the database
crap and simply be the following:

function fDisasterDescription_write3(aryNewD)

dim strTypeID, strDescription, strDate, intDisasterID

fDisasterDescription_write3 = 2

For i = 0 to ubound(aryNewD, 2)
strTypeID = aryNewD(1, i)
strDescription = aryNewD(3, i)
strDate = aryNewD(2, i)
intDisasterID = aryNewD(0, i)

response.write strTypeID & ", " & strDescription
& ", " & strDate & ", " & intDisasterID & "<br>"
Next

if err.number > 0 then
fDisasterDescription_Write3 = 2
else
fDisasterDescription_Write3 = 1
end if

end function
I still have the same type mismatch error. Help?
-----Original Message-----
Checked - it is an array, but still no go with the
function. Other ideas?
-----Original Message-----
You should use the IsArray function to test that it is

actually an array,
before calling the function, or in the first part of the
function.

"Laura" <Pl**********@to.the.newsgroup> wrote in message
news:85****************************@phx.gbl...
Help. Below is my code. Getting Type mismatch error

on
the noted line. I'm trying to send an array (aryNewD)
with 4 columns and x rows to a function to save all

the array info into a SQL Server table via a stored
procedure. Keep getting this error. Any suggestions?

Code:
'ASP:

if blnNewD then
dim blnWrite
if fDisasterDescription_Write2(aryNewD) = 1
then 'ERROR MESSAGE POINTS TO THIS LINE
blnWrite = True
else
blnWrite = False
end if
if not blnWrite then blnValid = False
if blnValid = False then
response.write "An error has occured."
response.end
end if
end if

'----------------------------------------------------- -
---
-----------------------------
'Function:

function fDisasterDescription_Write2(aryNewD)
dim conDisasterWaste, cmdDisasterWaste,
blnCriticalError
dim param1, param2, param3, param4, param5
dim my_adCmdStoredProc, my_adChar, my_adInteger,
my_adParamInput
dim my_adSmallInt, my_adVarChar, my_adDate
dim strTypeID, strDescription, strDate,

intDisasterID

my_adCmdStoredProc = &H0004
my_adChar = 129
my_adInteger = 3
my_adParamInput = &H0001
my_adSmallInt = 2
my_advarchar = 200
my_adDate = 7

'Set the Connection Object

set conDisasterWaste = server.createobject
("ADODB.Connection")

conDisasterWaste.Open "database", "username", "password"

'Run stored procedure

set cmdDisasterWaste = server.CreateObject
("ADODB.Command")

set cmdDisasterWaste.ActiveConnection =
conDisasterWaste
cmdDisasterWaste.CommandType = my_adCmdStoredProc
cmdDisasterWaste.CommandText
= "tf_insert_DisasterDescription"

set param1 = cmdDisasterWaste.CreateParameter
("@idLandfill", my_adChar, my_adParamInput, 12)
set param2 = cmdDisasterWaste.CreateParameter
("@typeID", my_adSmallint, my_adParamInput)
set param3 = cmdDisasterWaste.CreateParameter
("@description", my_advarchar, my_adParamInput, 1000)
set param4 = cmdDisasterWaste.CreateParameter

("@date",
my_adDate, my_adParamInput)
set param5 = cmdDisasterWaste.CreateParameter
("@disasterid", my_adinteger, my_adParamInput)

cmdDisasterWaste.Parameters.Append(param1)
cmdDisasterWaste.Parameters.Append(param2)
cmdDisasterWaste.Parameters.Append(param3)
cmdDisasterWaste.Parameters.Append(param4)
cmdDisasterWaste.Parameters.Append(param5)

cmdDisasterWaste.Parameters("@idlandfill") =

Session ("idlandfill")

For i = 0 to ubound(aryNewD, 2)
strTypeID = aryNewD(1, i)
strDescription = aryNewD(3, i)
strDate = aryNewD(2, i)
intDisasterID = aryNewD(0, i)

cmdDisasterWaste.Parameters("@typeID") =

strTypeID
cmdDisasterWaste.Parameters("@description") =
strDescription
cmdDisasterWaste.Parameters("@date") = strDate
cmdDisasterWaste.Parameters("@disasterid") =
intDisasterID

cmdDisasterWaste.execute
Next

If Err.number = 0 then
fDisasterDescription_Write2 = 1
Else
fDisasterDescription_Write2 = 2
Response.Write(err.description & "<br>")
end if

set cmdDisasterWaste.ActiveConnection = Nothing
set cmdDisasterWaste = Nothing

conDisasterWaste.Close
set conDisasterWaste = Nothing
end function

THANK YOU!

.

.

Jul 19 '05 #4
Have you tried forcing the type?
like: cint(var1) = cint(var1)

"Laura" <Pl**********@to.the.newsgroup> wrote in message
news:85****************************@phx.gbl...
Help. Below is my code. Getting Type mismatch error on
the noted line. I'm trying to send an array (aryNewD)
with 4 columns and x rows to a function to save all the
array info into a SQL Server table via a stored
procedure. Keep getting this error. Any suggestions?

Code:
'ASP:

if blnNewD then
dim blnWrite
if fDisasterDescription_Write2(aryNewD) = 1
then 'ERROR MESSAGE POINTS TO THIS LINE
blnWrite = True
else
blnWrite = False
end if
if not blnWrite then blnValid = False
if blnValid = False then
response.write "An error has occured."
response.end
end if
end if

'---------------------------------------------------------
-----------------------------
'Function:

function fDisasterDescription_Write2(aryNewD)
dim conDisasterWaste, cmdDisasterWaste,
blnCriticalError
dim param1, param2, param3, param4, param5
dim my_adCmdStoredProc, my_adChar, my_adInteger,
my_adParamInput
dim my_adSmallInt, my_adVarChar, my_adDate
dim strTypeID, strDescription, strDate, intDisasterID

my_adCmdStoredProc = &H0004
my_adChar = 129
my_adInteger = 3
my_adParamInput = &H0001
my_adSmallInt = 2
my_advarchar = 200
my_adDate = 7

'Set the Connection Object

set conDisasterWaste = server.createobject
("ADODB.Connection")

conDisasterWaste.Open "database", "username", "password"

'Run stored procedure

set cmdDisasterWaste = server.CreateObject
("ADODB.Command")

set cmdDisasterWaste.ActiveConnection =
conDisasterWaste
cmdDisasterWaste.CommandType = my_adCmdStoredProc
cmdDisasterWaste.CommandText
= "tf_insert_DisasterDescription"

set param1 = cmdDisasterWaste.CreateParameter
("@idLandfill", my_adChar, my_adParamInput, 12)
set param2 = cmdDisasterWaste.CreateParameter
("@typeID", my_adSmallint, my_adParamInput)
set param3 = cmdDisasterWaste.CreateParameter
("@description", my_advarchar, my_adParamInput, 1000)
set param4 = cmdDisasterWaste.CreateParameter("@date",
my_adDate, my_adParamInput)
set param5 = cmdDisasterWaste.CreateParameter
("@disasterid", my_adinteger, my_adParamInput)

cmdDisasterWaste.Parameters.Append(param1)
cmdDisasterWaste.Parameters.Append(param2)
cmdDisasterWaste.Parameters.Append(param3)
cmdDisasterWaste.Parameters.Append(param4)
cmdDisasterWaste.Parameters.Append(param5)

cmdDisasterWaste.Parameters("@idlandfill") = Session
("idlandfill")

For i = 0 to ubound(aryNewD, 2)
strTypeID = aryNewD(1, i)
strDescription = aryNewD(3, i)
strDate = aryNewD(2, i)
intDisasterID = aryNewD(0, i)

cmdDisasterWaste.Parameters("@typeID") = strTypeID
cmdDisasterWaste.Parameters("@description") =
strDescription
cmdDisasterWaste.Parameters("@date") = strDate
cmdDisasterWaste.Parameters("@disasterid") =
intDisasterID

cmdDisasterWaste.execute
Next

If Err.number = 0 then
fDisasterDescription_Write2 = 1
Else
fDisasterDescription_Write2 = 2
Response.Write(err.description & "<br>")
end if

set cmdDisasterWaste.ActiveConnection = Nothing
set cmdDisasterWaste = Nothing

conDisasterWaste.Close
set conDisasterWaste = Nothing
end function

THANK YOU!
Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: s_m_b | last post by:
I am having a problem with a page that creates a treeview from a database, by reloading itself on each request for a new folder to be explored. The problem revolves around using an array to store...
2
by: Joshua Kolden | last post by:
STL allocators are templates so that when you write one you are obliged to make it work with any type. However, the Intel IPP library that we use has memory aligned allocators for each of 15...
4
by: Mike | last post by:
I am getting a type mismatch error when I do a bulk insert. ---Begin Error Msg--- Server: Msg 4864, Level 16, State 1, Line 1 Bulk insert data conversion error (type mismatch) for row 1, column...
3
by: Martin Lacoste | last post by:
Is there some issue with using too many left/right/mid/len functions in queries? Depending on the usage, they work fine, but... then there's here: SELECT Master_CAO.Incipit,...
0
by: news.paradise.net.nz | last post by:
I have been developing access databases for over 5 years. I have a large database and I have struck this problem with it before but can find nothing in help or online. Access 2000 I have a query...
31
by: CeZaR | last post by:
Hi, How can i specify the return type of a function returning a managed array of chars. If i try to write: "char __gc func()" i get an error! How can i do that? Thanks!
10
by: Yevgen Muntyan | last post by:
Consider the following macro: #define ALLOCIT(Type) ((Type*) malloc (sizeof (Type))) The intent is to wrap raw memory allocation of N bytes into a macro which returns allocated chunk of memory...
12
by: arnuld | last post by:
this is exercise 2-3 from the mentioned section. i have created a solution for it but i see errors and i tried to correct them but still they are there and mostly are out of my head: ...
19
by: zz12 | last post by:
Hello, is there a setting in IIS 5.0 that would quickly fix the following error?: Microsoft VBScript runtime (0x800A000D) Type mismatch It's strange because some of our .asp pages were...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.