B
Brian Henry
Hi, I am doing the following stored procedure
CREATE PROCEDURE [dbo].[RSMN_AddMessage]
@sender varchar(50),
@subject varchar(400),
@messagebody text,
@hasAttachments bit,
@sentTime DateTime
AS
insert into messages(sendername, subject, messagebody, hasattachments,
senttime)
values (@sender, @subject, @messagebody, @hasAttachments, @sentTime)
select scope_identity()
GO
which, the ID field of it (MessageID bigint) is a bigint data type in SQL
Server 2000... when I execute this in query anaylzer it works perfectly and
returns a ID number for the identity column MessageID... but when I run this
in VB.NET with this code
database.OpenConnection()
MessageID = CInt(cmdAddMessage.ExecuteScalar())
database.CloseConnection()
it comes back with this on my asp.net page as the error...
Server Error in '/' Application.
Object must implement IConvertible.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Object must implement
IConvertible.
Source Error:
Line 88: database.OpenConnection()
Line 89:
Line 90: MessageID = CInt(cmdAddMessage.ExecuteScalar())Line 91:
Line 92: database.CloseConnection()
Source File: c:\inetpub\wwwroot\SecurePages\Compose.aspx.vb Line: 90
Stack Trace:
[InvalidCastException: Object must implement IConvertible.]
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
System.Data.SqlClient.SqlCommand.ExecuteScalar()
hpsql.Compose.btnSendMessage_Click(Object sender, ImageClickEventArgs e)
in c:\inetpub\wwwroot\SecurePages\Compose.aspx.vb:90
System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e)
System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.Ra
isePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain() +1277
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET
Version:1.1.4322.573
what in the world is causing this? thanks! i also tried direct casting to
Int64 and Int32 and both failed the same way... BigInt should be a 64bit
integer from what ive heard...
CREATE PROCEDURE [dbo].[RSMN_AddMessage]
@sender varchar(50),
@subject varchar(400),
@messagebody text,
@hasAttachments bit,
@sentTime DateTime
AS
insert into messages(sendername, subject, messagebody, hasattachments,
senttime)
values (@sender, @subject, @messagebody, @hasAttachments, @sentTime)
select scope_identity()
GO
which, the ID field of it (MessageID bigint) is a bigint data type in SQL
Server 2000... when I execute this in query anaylzer it works perfectly and
returns a ID number for the identity column MessageID... but when I run this
in VB.NET with this code
database.OpenConnection()
MessageID = CInt(cmdAddMessage.ExecuteScalar())
database.CloseConnection()
it comes back with this on my asp.net page as the error...
Server Error in '/' Application.
Object must implement IConvertible.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Object must implement
IConvertible.
Source Error:
Line 88: database.OpenConnection()
Line 89:
Line 90: MessageID = CInt(cmdAddMessage.ExecuteScalar())Line 91:
Line 92: database.CloseConnection()
Source File: c:\inetpub\wwwroot\SecurePages\Compose.aspx.vb Line: 90
Stack Trace:
[InvalidCastException: Object must implement IConvertible.]
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
System.Data.SqlClient.SqlCommand.ExecuteScalar()
hpsql.Compose.btnSendMessage_Click(Object sender, ImageClickEventArgs e)
in c:\inetpub\wwwroot\SecurePages\Compose.aspx.vb:90
System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e)
System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.Ra
isePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain() +1277
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET
Version:1.1.4322.573
what in the world is causing this? thanks! i also tried direct casting to
Int64 and Int32 and both failed the same way... BigInt should be a 64bit
integer from what ive heard...