473,385 Members | 1,474 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,385 software developers and data experts.

Help with error msg...

Hello to all,

I need some help understanding why this is happening to
me plaase. I have the following routine written in
vb.net. I am trying to return data from a log table using
the sqlhelper dll. The query that ivestigates the
database generates the "System.InvalidCastException:
Object must implement IConvertible. at
System.Data.SqlClient.SqlCommand.ExecuteReader" .....

Here is the code that uses the ms provided application
block

' SqlDataReader that will hold the returned results

Dim ds As System.Data.DataSet = Nothing
' SqlConnection that will be used to execute the
sql commands
Dim connection As SqlConnection = Nothing

Try
Try
connection = GetConnection(m_DbConnStr)
Dim g As System.Guid

With m_oSqlHelper
.ClearParam(m_oParms)
.AddParam(m_oParms, "@Start_Date",
SqlDbType.DateTime, ParameterDirection.Input, 8,
Convert.ToDateTime(Me.txtStartDateTime.Text.ToStri ng))
System.Diagnostics.Debug.WriteLine
(Me.txtStartDateTime.Text.ToString)
.AddParam(m_oParms, "@End_Date",
SqlDbType.DateTime, ParameterDirection.Input, 8,
Convert.ToDateTime(Me.txtEndDateTime.Text.ToString ))
System.Diagnostics.Debug.WriteLine
(Me.txtEndDateTime.Text.ToString)
g = New System.Guid
(Me.ddlMachine.SelectedValue.ToString)
System.Diagnostics.Debug.WriteLine
(g.ToString)
.AddParam(m_oParms, "@Machine_Id",
SqlDbType.Char, ParameterDirection.Input, 16, g)
g = New System.Guid
(Me.ddlBusinessUnits.SelectedValue.ToString)
System.Diagnostics.Debug.WriteLine
(g.ToString)
.AddParam(m_oParms, "@Bu_ID",
SqlDbType.Char, ParameterDirection.Input, 16, g)
g = New System.Guid
(Me.ddlTechnician.SelectedValue.ToString)
System.Diagnostics.Debug.WriteLine
(g.ToString)
.AddParam(m_oParms, "@Users_ID_Id",
SqlDbType.Char, ParameterDirection.Input, 16, g)
g = New System.Guid
(Me.ddlMalfunctionTypes.SelectedValue.ToString)
System.Diagnostics.Debug.WriteLine
(g.ToString)
.AddParam
(m_oParms, "@malfunction_ID", SqlDbType.Char,
ParameterDirection.Input, 16, g)
End With

ds = m_oSqlHelper.ExecuteDataset
(connection,
CommandType.StoredProcedure, "sp_Get_OEEData_By_Date",
m_oParms)

Catch ex As Exception
With lblError
'.Text = "The connection with the
database canīt be established"
.Text = ex.ToString
.Visible = True
.Enabled = True
Exit Sub
End With

End Try

'bind datareader to datagrid
With Me.oDgReport
.DataSource = ds.Tables(0)
.DataBind()
End With

Catch ex As Exception
Dim errMessage As String = ""
Dim tempException As Exception = ex

While (Not tempException Is Nothing)
errMessage += tempException.Message +
Environment.NewLine + Environment.NewLine
tempException =
tempException.InnerException
End While

Finally
If Not ds Is Nothing Then
CType(ds, IDisposable).Dispose()
End If

If Not connection Is Nothing Then
CType(connection, IDisposable).Dispose()
End If
End Try
End Sub
The query works in qry analyzer. If I stop the code and
grab the sql syntax and run it in query analyzer it works
as advertised. It just won't run from .Net....any ideas?

Thanks in advance,
Pat
Nov 22 '05 #1
1 1353
Hello Pat,

Thanks for your post. Based on my experience, this exception means that
there is a conversion problem and the SqlClient managed provider does not
support IConvertable in order to perform the conversion. So, what this
error indicates is that when the query was executed one (or more) parameter
has failed to bind with the provided data type. To narrow down the problem,
I suggest that you can create a new Stored Procedure without any parameter
and see if it works. And then you can add the parameters one by one to the
Stored Procedure to check which one causes the problem.

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 22 '05 #2

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

Similar topics

6
by: wukexin | last post by:
Help me, good men. I find mang books that introduce bit "mang header files",they talk too bit,in fact it is my too fool, I don't learn it, I have do a test program, but I have no correct doing...
5
by: xuatla | last post by:
Hi, I encountered the following compile error of c++ and hope to get your help. test2.cpp: In member function `CTest CTest::operator+=(CTest&)': test2.cpp:79: error: no match for 'operator='...
9
by: YZK | last post by:
Hello. I'm not a Web developer, just a user, and I think I may have somehow messed myself up majorly. I'm not quite sure how. Right now, javascript used by websites I go to either does not work at...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
1
by: Dave | last post by:
I am having problems accessing DTS after install SP4 and was wondering if someone could offer some advice. I installed SP4 and got the following error after it competed. Unable to write to...
6
by: Jax | last post by:
I have Visual Studio 2002 Standard Edition. It has been working fine up to a point and now i'm at that point. Due to the limitations of the edition i am not using any of my own .dll's and instead...
5
by: Marc Violette | last post by:
<Reply-To: veejunk@sympatico.ca> Hello, I'm hoping someone can help me out here... I'm a beginner ASP.NET developper, and am trying to follow a series of exercises in the book entitled...
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
12
by: =?Utf-8?B?ZGdvdw==?= | last post by:
I designed a "contact_us" page in visual web developer 2005 express along with EW2 after viewing tutorials on asp.net's help page. Features work like they should, but I cannot figure out how to...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.