P
PatLaf
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.ToString))
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
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.ToString))
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