Hello friends,
I am creating a matrix object with some columns.
The process of creating the matrix and the columns is successful.
I created a button to perform the action to add the values entered in the matrix of fields in a user table. This process is successful.
After add the values entered in the columns in the database column is empty.
Would appear that the values in the column after added.
I used the parameter below however is not working.
oMatrix.LoadFromDataSource ()
Below my code.
----------------------------------------------------
oMktForm = SBO_Application.Forms.GetForm(FormTypeEx, FormTypeCount)
sboRecordSet = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
oEditText = oMktForm.Items.Item("10").Specific
ContractID = oEditText.Value
oItem = oMktForm.Items.Item("Matrix01")
oMatrix = oItem.Specific
Dim FTMCodigo As String = ""
Dim FTMDesc As String = ""
'Percorre as linhas do Matrix
Dim i As Integer
For i = 1 To oMatrix.VisualRowCount
oEditText = oMatrix.Columns.Item("FTMCodigo").Cells.Item(i).Specific
FTMCodigo = oEditText.Value
FTMDesc = oEditText.Value
oEditText = oMatrix.Columns.Item("FTMDesc").Cells.Item(i).Specific
'Se itemCode está preenchido
If FTMCodigo <> "" Then
'Confere se já tem esse item na tabela de Servicos do LocOne
sboRecordSet = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
strQuery = "SELECT"
strQuery &= " U_FTM_ContractID"
strQuery &= " FROM [@FTM_CBRA] (NOLOCK) "
strQuery &= " WHERE U_FTM_ContractID = '" & ContractID & "'"
strQuery &= " AND U_FTM_CodeCobertura = '" & FTMCodigo & "'"
sboRecordSet.DoQuery(strQuery)
If sboRecordSet.RecordCount = 0 Then
Dim ProxID As String
'busca prox ID
strQuery = "SELECT ISNULL(MAX(Cast(Code as Int))+1,1) as Code FROM [@FTM_CBRA] (NOLOCK) "
sboRecordSet.DoQuery(strQuery)
ProxID = CStr(sboRecordSet.Fields.Item(0).Value)
'Insere o item
strQuery = "INSERT INTO [@FTM_CBRA] "
strQuery &= " (Code, Name,"
strQuery &= " U_FTM_ContractID,"
strQuery &= " U_FTM_Codecobertura,"
strQuery &= " U_FTM_Descricao"
strQuery &= " )"
strQuery &= " VALUES"
strQuery &= " ('" & ProxID & "', '" & ProxID & "',"
strQuery &= " '" & ContractID & "',"
strQuery &= " '" & FTMCodigo & "',"
strQuery &= " '" & FTMDesc & "'"
strQuery &= " )"
sboRecordSet.DoQuery(strQuery)
End If
End If 'Se itemCode está preenchido
'Limpa matriz para inserir os dados
'oMatrix.Clear()
oMktForm.DataSources.DataTables.Item("DTM01").Rows.Add()
oMatrix.AutoResizeColumns()
oMatrix.LoadFromDataSource()
----------------------------------------------------