I am trying to use stored procedures for the first time and have created the following script which is giving me an error and I don't know why. Here is my code
Sub update_click( s As Object, e As EventArgs )
Dim dbconn1 As SqlConnection = New SqlConnection("server=AM1ST_FS1;database=HRINFO;uid=sa;"
Dim mycommand as SqlCommand
dbconn1.open()
mycommand = New SqlCommand( "insertupdate", dbconn1 )
mycommand.CommandType = CommandType.StoredProcedure
mycommand.Parameters.Add( New SqlParameter( "@firstName", SqlDBType.nvarchar, 50 ))
mycommand.Parameters( "@firstname" ).Value = firstName
mycommand.Parameters.Add( New SqlParameter( "@lastName", SqlDBType.nvarchar, 50 ))
mycommand.Parameters( "@lastName" ).Value = lastName
mycommand.Parameters.Add( New SqlParameter( "@address", SqlDBType.nvarchar, 50 ))
mycommand.Parameters( "@address" ).Value = address
mycommand.Parameters.Add( New SqlParameter( "@city", SqlDBType.nvarchar, 50 ))
mycommand.Parameters( "@city" ).Value = city
mycommand.Parameters.Add( New SqlParameter( "@state", SqlDBType.nvarchar, 50 ))
mycommand.Parameters( "@state" ).Value = state
mycommand.Parameters.Add( New SqlParameter( "@ssn", SqlDBType.nvarchar, 50 ))
mycommand.Parameters( "@ssn" ).Value = ssn
mycommand.Parameters.Add( New SqlParameter( "@gender", SqlDBType.nvarchar, 50 ))
mycommand.Parameters( "@gender" ).Value = gender
mycommand.Parameters.Add( New SqlParameter( "@emergancy", SqlDBType.nvarchar, 50 ))
mycommand.Parameters( "@emergancy" ).Value = emergancycontact
mycommand.Parameters.Add( New SqlParameter( "@loginID", SqlDBType.nvarchar, 50 ))
mycommand.Parameters( "@loginID" ).Value = loginID
mycommand.ExecuteNonQuery()
dbconn1.close
End Sub
HERE IS THE ERROR
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 101:mycommand.Parameters( "@loginID" ).Value = loginID
Line 102:
Line 103:mycommand.ExecuteNonQuery()
Line 104:dbconn1.close
Line 105:
Source File: E:\Intranet\Mystuff\Mystuff\aspnet\index.aspx Line: 103
Stack Trace:
[InvalidCastException: Object must implement IConvertible.]
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) +643
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +206
ASP.index_aspx.update_click(Object s, EventArgs e) in E:\Intranet\Mystuff\Mystuff\aspnet\index.aspx:103
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1263
--------------------------------------------------------------------------------
Any Help would be great!
Sub update_click( s As Object, e As EventArgs )
Dim dbconn1 As SqlConnection = New SqlConnection("server=AM1ST_FS1;database=HRINFO;uid=sa;"
Dim mycommand as SqlCommand
dbconn1.open()
mycommand = New SqlCommand( "insertupdate", dbconn1 )
mycommand.CommandType = CommandType.StoredProcedure
mycommand.Parameters.Add( New SqlParameter( "@firstName", SqlDBType.nvarchar, 50 ))
mycommand.Parameters( "@firstname" ).Value = firstName
mycommand.Parameters.Add( New SqlParameter( "@lastName", SqlDBType.nvarchar, 50 ))
mycommand.Parameters( "@lastName" ).Value = lastName
mycommand.Parameters.Add( New SqlParameter( "@address", SqlDBType.nvarchar, 50 ))
mycommand.Parameters( "@address" ).Value = address
mycommand.Parameters.Add( New SqlParameter( "@city", SqlDBType.nvarchar, 50 ))
mycommand.Parameters( "@city" ).Value = city
mycommand.Parameters.Add( New SqlParameter( "@state", SqlDBType.nvarchar, 50 ))
mycommand.Parameters( "@state" ).Value = state
mycommand.Parameters.Add( New SqlParameter( "@ssn", SqlDBType.nvarchar, 50 ))
mycommand.Parameters( "@ssn" ).Value = ssn
mycommand.Parameters.Add( New SqlParameter( "@gender", SqlDBType.nvarchar, 50 ))
mycommand.Parameters( "@gender" ).Value = gender
mycommand.Parameters.Add( New SqlParameter( "@emergancy", SqlDBType.nvarchar, 50 ))
mycommand.Parameters( "@emergancy" ).Value = emergancycontact
mycommand.Parameters.Add( New SqlParameter( "@loginID", SqlDBType.nvarchar, 50 ))
mycommand.Parameters( "@loginID" ).Value = loginID
mycommand.ExecuteNonQuery()
dbconn1.close
End Sub
HERE IS THE ERROR
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 101:mycommand.Parameters( "@loginID" ).Value = loginID
Line 102:
Line 103:mycommand.ExecuteNonQuery()
Line 104:dbconn1.close
Line 105:
Source File: E:\Intranet\Mystuff\Mystuff\aspnet\index.aspx Line: 103
Stack Trace:
[InvalidCastException: Object must implement IConvertible.]
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) +643
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +206
ASP.index_aspx.update_click(Object s, EventArgs e) in E:\Intranet\Mystuff\Mystuff\aspnet\index.aspx:103
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1263
--------------------------------------------------------------------------------
Any Help would be great!