errors with application data block

  • Thread starter Thread starter Phil Townsend
  • Start date Start date
P

Phil Townsend

I have been using the MS Applicatin data block for over a year without
error. Recently, when calling ExecuteReader or ExecuteDataSet with a
parameterized stored procedure, I am receiving the following error:
Object must implement IConvertible. This only occurs when the procedure
expects parameters--procedures that don't take parameters work fine. The
error is coming from the data block. I am not dong anything any
different than I have for over a year of using the application data
blocks. A simplified code sample follows. Any clues as to why this is
suddenly happening? Anything I may not have checked? Thanks...

SqlDataReader drcheck=SqlHelper.ExecuteReader(
conn,"checklogin",
new SqlParameter("@un",username),
new SqlParameter("@pw",password));

ALTER PROCEDURE dbo.checkLogin
@un varchar(50),@pw varchar(50)
AS
SET NOCOUNT ON
select * from employees where email=@un and password=@pw
RETURN
 
Phil,

The application data block comes with full source code. Have you tried
debugging it yourself? It shouldn't be too hard to pin down the error with
the source code.

Hope this helps.
 
Hi Phil,

In this statement:
SqlDataReader drcheck=SqlHelper.ExecuteReader(
conn,"checklogin",
new SqlParameter("@un",username),
new SqlParameter("@pw",password));

how are the variables 'username' and 'password' declared? The constructor
for SqlParameter allows the second parameter to be declared as type Object
as long as that object implements IConvertible. If username and password
are not string objects, but are classes or some other object that doesn't
implement IConvertible, then you will get this error.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
 
Back
Top