on 04-11-2006 11:10 AM
I created a table called @PTSFCT in SB1. Now I would like to insert data in the fields of the table. How can I do it?
On Insert data I don´t use select. How to Updat a register in the table?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi.
Is You can`t update them with an object, You can use RecordSet.
Here is some code in C++:
SAPbobsCOM::IRecordSetPtr record;
record=m_Cmp->GetBussinessObject(SAPbobsCOM::boRecordSet);
//m_Cmp - is the company object;
_bstr_t m_Query;
m_Query = L"insert into [@table] (field1, field2...) values (value1, value2...)";
long ret;
ret = record->DoQuery(m_Query);
You can use Select, Update, Insert, Delete in m_Query (String).
Check ret code - if =0 then all is ok, else use:
m_cmp->GetLastError(*long, *BSTR);
Sorry for my english.
Hope it helps.
Kamil Wydra.
Hi Kamil,
Thank you very much for your engagement - obviously I had overlooked the question regarding updates...)!
...BUT:
You can use the Update() (Remove() exists as well) method of the UserTable object.
However, developers have the freedom to choose the update / insert / delete of UDTs using SQL at the cost of some DB dependency (DB2 is a bit different in handling UDTs ASFAIK).
Regards,
Frank
Hi
Here is an example, im assuming you want to do it through the sdk.
Dim oUserTable As SAPbobsCOM.UserTable
'Use the user table we added before
oUserTable = oCompany.UserTables.Item("SOS_OENQ")
'Add a first row in the table
oUserTable.Code = Value
oUserTable.Name = Value
oUserTable.UserFields.Fields.Item("U_ComName").Value = CompanyName
oUserTable.UserFields.Fields.Item("U_ComTel").Value = CompanyTel
oUserTable.UserFields.Fields.Item("U_CntName").Value = ContactName
oUserTable.UserFields.Fields.Item("U_CntTel").Value = ContactTel
oUserTable.UserFields.Fields.Item("U_Brnch").Value = oCombo.Selected.Value
lRetCode = oUserTable.Add
You must check lretcode, it should be zero, if not it means it was not successfull.
Hope this helps
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
oCompany is the SAPbobsCOM.company class. declare as
<b>SAPbobsCOM.Company oCompany; (C#)</b>
lRetCode is a long interger for error handling... so simply:
<b>int iRetCode = 0; (C#)</b>
however before you use oCompany you have to connect the oCompany to the SBO of your choice... using the following block of code:
int lErrCode = 0;
int IRetCode = 0;
string sErrMsg = string.empty;
oCompany.Server = "Your server"; (if it's a local server then just put in "(local)")
oCompany.CompanyDB = "yourcompanydb" (for example SBODemo_US;
oCompany.UserName = "your SBO username"; (have to be administrator)
oCompany.Password = "you SBO password";
// Connecting to a company DB
lRetCode = oCompany.Connect();
if ( lRetCode != 0 )
{
oCompany.GetLastError( out lErrCode, out sErrMsg );
Application.MessageBox.Show("You got error: "+sErrMsg);
}
else {
Application.MessageBox.Show( "Connected to " + globals.oCompany.CompanyName);
}
A very good way to get all these informations are in the Sample files in the SDK.. provide both C#, VB.net and JAVA codes... I just started using SDK a month ago myself. The Samples files help me greatly!
Message was edited by: Bo Peng
Please download the SDK Helpcenter (available from the SAP Business One Developer Area) + go over the brief introductory sections - e.g. for DI API - so that you better know where to go/start.
...it even contains sample code snippets...
Please read the "SAP Business One Forum news... " thread:
=> Besides other links you will find a link where you can download the (basic) E-learning flashbooks for the B1 SDK.
Please check-out the SDK samples (as suggested by Bo).
User | Count |
---|---|
97 | |
11 | |
11 | |
6 | |
6 | |
4 | |
4 | |
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.