HI,
Thank you for your help, but now I am getting a different error
A value of type 'System.DBNull' cannot be set to the location with name 'NewAccountID' because it is a location of type 'System.String'.
My full code
Protected Overrides Sub Execute(Executioncontext As CodeActivityContext)
Dim _licence As String = new_licence.[Get](Executioncontext).ToString
Dim _sun As String = new_sun.[Get](Executioncontext).ToString
Dim _sortcode As String = new_sortcode.[Get](Executioncontext).ToString
Dim _accountnumber As String = new_accountnumber.[Get](Executioncontext).ToString
Dim _acountname As String = new_accountname.[Get](Executioncontext).ToString
Dim _allowcredits As Boolean = new_allowcredits.[Get](Executioncontext)
Dim _allowdebits As Boolean = new_allowdebits.[Get](Executioncontext)
Try
Dim sql_connection As New SqlClient.SqlConnection(SQLConnectionString)
' Add record to legacy system
Dim SQL_Command As New SqlClient.SqlCommand
SQL_Command.CommandType = CommandType.StoredProcedure
SQL_Command.CommandText = "sp_AddNewOriginatingAccount"
SQL_Command.Connection = sql_connection
SQL_Command.Parameters.Add("@Licence", SqlDbType.VarChar, 6, ParameterDirection.Input).Value = _licencenumber
SQL_Command.Parameters.Add("@BACSID", SqlDbType.VarChar, 6, ParameterDirection.Input).Value = _sun
SQL_Command.Parameters.Add("@SortCode", SqlDbType.VarChar, 6, ParameterDirection.Input).Value = _sortcode
SQL_Command.Parameters.Add("@AccountNumber", SqlDbType.VarChar, 8, ParameterDirection.Input).Value = _accountnumber
SQL_Command.Parameters.Add("@AccountName", SqlDbType.VarChar, 32, ParameterDirection.Input).Value = _acountname
SQL_Command.Parameters.Add("@ALLOWPAYMENTS", SqlDbType.Bit, ParameterDirection.Input).Value = _allowcredits
SQL_Command.Parameters.Add("@ALLOWDEBITS", SqlDbType.Bit, ParameterDirection.Input).Value = _allowdebits
SQL_Command.Parameters.Add("@rtnNextAccountId", SqlDbType.VarChar, 6)
SQL_Command.Parameters("@rtnNextAccountId").Direction = ParameterDirection.Output
SQL_Command.Parameters.Add("@rtnOAccountID", SqlDbType.VarChar, 50)
SQL_Command.Parameters("@rtnOAccountID").Direction = ParameterDirection.Output
sql_connection.Open()
SQL_Command.ExecuteNonQuery()
sql_connection.Close()
NextAccountID.[Set](Executioncontext, SQL_Command.Parameters("@rtnNextAccountId").Value)
NewAccountID.[Set](Executioncontext, SQL_Command.Parameters("@rtnOAccountID").Value)
Catch sqlex As Exception
ErrorReporting(sqlex.Message.ToString)
End Try
End Sub
Public Function ErrorReporting(errormessage As String) As Boolean
Using sw As StreamWriter = File.AppendText(ErrorReport)
sw.WriteLine(errormessage)
End Using
Return True
End Function
<RequiredArgument>
<Input("new_licence")>
Public Property new_licence() As InArgument(Of String)
Get
Return m_new_licence
End Get
Set
m_new_licence = Value
End Set
End Property
Private m_new_licence As InArgument(Of String)
<RequiredArgument>
<Input("new_sun")>
Public Property new_sun() As InArgument(Of String)
Get
Return m_new_sun
End Get
Set
m_new_sun = Value
End Set
End Property
Private m_new_sun As InArgument(Of String)
<RequiredArgument>
<Input("new_sortcode")>
Public Property new_sortcode() As InArgument(Of String)
Get
Return m_new_sortcode
End Get
Set
m_new_sortcode = Value
End Set
End Property
Private m_new_sortcode As InArgument(Of String)
<RequiredArgument>
<Input("new_accountnumber")>
Public Property new_accountnumber() As InArgument(Of String)
Get
Return m_new_accountnumber
End Get
Set
m_new_accountnumber = Value
End Set
End Property
Private m_new_accountnumber As InArgument(Of String)
<RequiredArgument>
<Input("new_accountname")>
Public Property new_accountname() As InArgument(Of String)
Get
Return m_new_accountname
End Get
Set
m_new_accountname = Value
End Set
End Property
Private m_new_accountname As InArgument(Of String)
<RequiredArgument>
<Input("new_allowcredits")>
Public Property new_allowcredits() As InArgument(Of Boolean)
Get
Return m_new_allowcredits
End Get
Set
m_new_allowcredits = Value
End Set
End Property
Private m_new_allowcredits As InArgument(Of Boolean)
<RequiredArgument>
<Input("new_allowdebits")>
Public Property new_allowdebits() As InArgument(Of Boolean)
Get
Return m_new_allowdebits
End Get
Set
m_new_allowdebits = Value
End Set
End Property
Private m_new_allowdebits As InArgument(Of Boolean)
<Output("Next Account ID")>
Public Property NextAccountID As OutArgument(Of String)
<Output("New Account ID")>
Public Property NewAccountID As OutArgument(Of String)