on 03-11-2009 3:46 AM
Hi All,
I have this AddOn, which im using a UDT and registered it in UDO. My UDT's object type is MasterData.
On the saving part, i wasnt able to add a record and keep on getting this error: "Master Data Type UserTable can not add row" please tell me why..
'i have this code on the saving part:
Private Sub AddProdHierarchyToDatabase()
Dim ut As SAPbobsCOM.UserTable
Dim uts As SAPbobsCOM.UserTables
Dim rs As SAPbobsCOM.Recordset
Dim sql As String = String.Empty
Dim lastCode As Integer
Try
'get last code
rs = _company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
sql = "Select COUNT(Code) As LastCode From dbo.[@SMC_ProdHierarchy]"
rs.DoQuery(sql)
lastCode = rs.Fields.Item("LastCode").Value + 1
uts = _company.UserTables
ut = uts.Item("SMC_ProdHierarchy")
ut.Code = lastCode
ut.Name = "6"
ut.UserFields.Fields.Item("U_lookupCode").Value = Module1.HierarchyCode
ut.Add()
ut.Update()
Catch ex As Exception
End Try
End Sub
-Roger
Why do you do call both Add and Update :
ut.Add()
ut.Update()
Add is to insert a new line in the table, Update is to modify an existing row. You should only call the Add method in this case.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
109 | |
15 | |
10 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.