Thursday, 23 October 2008
Disconnecting from Sage
Some users of the SDO have informed us of an intermittent problem, where the user can be left logged into Sage once a Disconnect() has been called. The brute-force solution to this was to delete the QUEUE.DTA file in the ACCDATA folder, but this is best avoided.
A simple but novel solution was put forward by one of our users, to simply change the GUID in the Connect() parameters to the Username, and from all accounts, this seems to work.
Wednesday, 22 October 2008
Quirky IsEOF()
IsEOF() is flagged true after reading the second-last record. That is to say, if you have 10 records, after reading record 9, then IsEOF() becomes true. This means you can still read record 10, but no more.
The code example in the download from the website, actually misses this point, so here's how to fix it:
SageDataObject50.SalesRecord srCustomer50 = (SageDataObject50.SalesRecord)ws50.CreateObject("SalesRecord");
srCustomer50.MoveFirst();
bool blnLast = false;
while(true)
{
strDescription = srCustomer50.Fields.Item(ref objDescription).Value.ToString();
this.lvCustomer.Items.Add(strDescription);
srCustomer50.MoveNext();
if (blnLast) break;
blnLast = srCustomer50.IsEOF();
}
break;
The code added is highlighted in brown. Note how IsEOF is flagged before the last record is read.
Wednesday, 8 October 2008
Type Safety with Sage
Here is an example of the problem, in Visual Basic.NET
InvPost.Header("Items_Net").value = 13
? InvPost.Header("Items_Net").value
4.7229610327708223E+275 {Double}
[Double]: 4.7229610327708223E+275 {Double}
InvPost.Header("Items_Net").value = CType(13,Double)
? InvPost.Header("Items_Net").value
13.0 {Double}
[Double]: 13.0 {Double}
Here, Items_Net is expecting a floating point value, but when assigned with an integer, it ignores the value, and does not throw an exception. Converting the type to a double, and the code works as expected.
To avoid this, you should be familiar with the types of all the fields that you use, and to do so, you should study the schema for your particular version of Sage, as explained in this link
http://sagedataobjects.blogspot.com/2008/05/exploring-sage-data-schema.html
Thursday, 2 October 2008
Adding and Removing Customers with Visual Basic
http://www.sagedataobjects.com/sagecustomersvb.zip (3Kb)
Thursday, 18 September 2008
Reading and Updating Departments in Sage
Reading and updating departments in Sage via Sage Data Objects is easy, and here's how.
Reading departments:
Dim IDepartment As SageDataObject50.Department
Dim strDescription As String
IDepartment = DirectCast(ws50.CreateObject("DepartmentData"), SageDataObject50.Department)
Dim i As Int16
For i = 0 To 100
IDepartment.Read(i)
strDescription = IDepartment.Fields.Item("NAME").Value.ToString()Me.lvDepartments.Items.Add(strDescription)
Next
To update them, you just use the write(int) method.
Dim IDepartment As SageDataObject50.Department
Dim strDescription As String
IDepartment = DirectCast(ws50.CreateObject("DepartmentData"), SageDataObject50.Department)
Dim i As Int16
For i = 0 To 100
IDepartment.Fields.Item("NAME").Value = "RESET"
IDepartment.Write(i)
Next
Tuesday, 2 September 2008
Read/Write ODBC connection for Sage
A company we were speaking to offer a ODBC SDK on a 15 day trial basis, and we'd be interested in hearing from anyone who can integrate our component with this SDK to create a read/write ODBC connection with Sage.
Here's the link to the ODBC SDK
http://www.datadirect.com/downloads/registration/sdk_eval/index.ssp
Tuesday, 26 August 2008
Schema for Sage Line 50 Financial Controller
http://www.sagedataobjects.com/line50financialcontroller.asp