Unable to set up emailReader

T

tshad

I have a dataReader that was used a second time in the same routine and got
the following error:

Object must implement IConvertible.

It worked fine just before.

I did a stored procedure call just before, closed the connection, set up the
new parameters for another stored procedure and got the error when it did:

emailReader = objCmd.ExecuteReader

The code (after the 1st stored procedure is):

*****************************************************************
objConn.Close
objCmd.CommandText = "AddNewApplicantProfileAbsentee"

objCmd.Parameters.Clear()
with objCmd.Parameters
.Add("@ClientID",SqlDbType.VarChar,20).value = session("ClientID")
.Add("@ApplicantProfileID",SqlDbType.Bigint).value = ApplicantProfileID
end with
objConn.Open()
itemp = 1
emailReader = objCmd.ExecuteReader
while emailReader.Read
if not (emailReader("From") is DBNull.Value) then
txt = DirectCast(Page.FindControl("AbsentFrom" & itemp),TextBox)
txt.Text = emailReader("From")
end if
if not (emailReader("To") is DBNull.Value) then
txt = DirectCast(Page.FindControl("AbsentTo" & itemp),TextBox)
txt.Text = emailReader("From")
end if
if not (emailReader("Reason") is DBNull.Value) then
txt = DirectCast(Page.FindControl("AbsentReason" & itemp),TextBox)
txt.Text = emailReader("From")
end if
**********************************************************

I've done this before without any problems - what is this IConvertible
business?

Thanks,

Tom
 
T

tshad

tshad said:
I have a dataReader that was used a second time in the same routine and got
the following error:

Object must implement IConvertible.

It worked fine just before.

I found the problem. I had been passing ApplicantProfileID as a parameter
value. The problem is that ApplicantProfileID is a TextBox and you can't
use a TextBox as a value.

The statement should have been:

.Add("@ApplicantProfileID",SqlDbType.Bigint).value =
ApplicantProfileID.Text

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top