Archive

Archive for July, 2005

Connection string for Sage ODBC via OLEDB

Provider=MSDASQL.1;Persist Security Info=False;User ID=Manager;Data Source=SageLine50v9;Extended Properties="DSN=SageLine50v9;UID="
 
When Sage Line 50 is installed, it creates a system ODBC DSN called SageLine50v9 (I assume other versions of sage have corresponding names). The "database "contains the following tables:
 
TABLES
COMPANY
PERIOD
SALES_LEDGER
PURCHASE_LEDGER
NOMINAL_LEDGER
AUDIT_HEADER
AUDIT_SPLIT
AUDIT_JOURNAL
AUDIT_VAT
AUDIT_USAGE
DEPARTMENT
BANK
STOCK
STOCK_TRAN
STOCK_CAT
STOCK_COMP
INVOICE
SALES_ORDER
PURCHASE_ORDER
RECURRING
FIXED_ASSET
FIXED_ASSET_CAT
PREPAYMENT
ACCRUAL
INVOICE_ITEM
SOP_ITEM
POP_ITEM
SALES_CONTACT
PURCHASE_CONTACT
SALES_DEL_ADDR
PURCHASE_DEL_ADDR
COMPANY_DEL_ADDR
PRICE
PRICE_LIST
GRN_ITEM
CHART_LIST
CAT_TITLE
CATEGORY
TAX_CODE
UPDATE_LEDGER
CURRENCY
VAT_SUMMARY
VAT_RETURN
REMITTANCE
Categories: Uncategorized

Bad page viewstate in asp.net

Everybody who has worked with ASP.NET will be aware of the page viewstate. .NET’s way of persisting session information using hidden values on the page. However, you may find that if you accidentally post a viewstate from one page to another, or for some reason the worker process looses track of the page viewstate (such as within a server farm, or, as I suspect, where multiple worker processes are handling the same client) – you get an error such as the following:
 
[HttpException (0x80004005): Unable to validate data.]
   System.Web.Configuration.MachineKey.GetDecodedData(Byte[] buf, Byte[] modifier, Int32 start, Int32 length, Int32& dataLength) +195
   System.Web.UI.LosFormatter.Deserialize(String input) +60
[HttpException (0x80004005): Authentication of viewstate failed.  1) If this is a cluster, edit <machineKey> configuration so all servers use the same validationKey and validation algorithm.  AutoGenerate cannot be used in a cluster.  2) Viewstate can only be posted back to the same page.  3) The viewstate for this page might be corrupted.]
   System.Web.UI.LosFormatter.Deserialize(String input) +118
   System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +101
[HttpException (0x80004005): Invalid_Viewstate
 
You can of course, use persistant storage, such as SQL server to store the viewstate, but if it is just a rare occurance, you can have the page handle the event gracefully as follows
 

protected override object LoadPageStateFromPersistenceMedium()

{

object pageState;

try

{

pageState = base.LoadPageStateFromPersistenceMedium();

}

catch

{

// Something has gone wrong, reload page back to a stable state.

pageState = null;

Response.Redirect(Request.RawUrl);

}

return pageState;

}

 
That is, if the viewstate’s bad. then reload the page without any post data.
 
You can also return null from this procedure without redirecting, but this may have some unusual side effects.
Categories: Uncategorized

Google Maps API

After being quite amazed at Google earth, I had a look to see if there was an API available. The closest I can find is Google maps API (http://www.globefinder.info/googleMapAPI.html) – Although, an excellent web-based map, it doesn’t show terrain, or show houses and buildings like the Google Earth App.
 
Pity.
Categories: Uncategorized

Nokia 3210 opening instructions

Nokia 3210 opening instructions:

(1) Scrabble at case with fingernails, break 3 fingernails in process.

(2) wedge knife down side of case, twist until knife buckles

(3) push cover against door and wedge 2p into plastic cover.

(4) Try to retrieve 2p with buckled knife

(5) cover should snap violently open, with battery thrown accross room.

 

 

 

Categories: Uncategorized

Iterating products from sage

I was working on a bit of code to iterate through all products stored within sage, eventually found it (code in VB.NET)
 

Dim SDO As New SageDataObject90.SDOEngine

Dim wsStock As SageDataObject90.WorkSpace

Dim srStock As SageDataObject90.StockRecord

Dim i As Short

Dim strDescription As String

Dim strStockCode As String

wsStock = SDO.Workspaces.Add("Myconnection")

wsStock.Connect(SageLocation, SageUsername, SagePassword, "ThisIsUnique")

srStock = wsStock.CreateObject("StockRecord")

srStock.MoveFirst()

Do

strDescription = srStock.Fields.Item("DESCRIPTION").Value

strStockCode = srStock.Fields.Item("STOCK_CODE").Value

srStock.MoveNext()

Loop Until srStock.IsEOF

wsStock.Disconnect()

Categories: Uncategorized

Sage data objects

For anybody developing software to integrate with sage, here’s a tip which will save the £1,500 enrollment fee in the sage developer program. You can download the Sage data objects from http://www.eosuk.com/downloads/downloadsuk.htm
 
If you copy the relevant TLB (type library files) into Windows/system32 on a machine that previously had Sage installed (i.e. SDOENG90.dll is in the system folder) you can then make a COM reference to the type library. And for those .NETter’s out there, i’m sure you can create the wrapper class from that.
 
 
Categories: Uncategorized

C# Library for ZIM

Just finished developing a C# Library for te ZIM platform.  used VSHIK and NDOC to document the class, and it looks quite well, apart from some classes that are really for internal use only appearing in the documentation… I guess they’re supposed to be "Sealed" or something.
 
 
 
Categories: Uncategorized

Running a block of SQL files sequentially

In Enterprise manager, you can script out the schema of a database, including stored procedures & all by clicking All-Tasks then "Generate SQL script". In this you have an option to create one big SQL file, or one file per object.
 
I opted for one file per object, because, I wanted to create a database project, in order to put the database schema under source control, and thus multiple developers could change the database schema at the same time.
But this time, with version tracking, and all the other associated benifits of source control.
 
However, when you are left with 1000 or so SQL files, how do you run them all together. – I used a batch file like this:
 
@echo off
cls
echo Databse installation utility
echo ——————————————
echo Useage: InstallDB [server] [database name]
for %%1 in (*.*) do osql -S %1 -E -d %2 -i %%1 -n
 
(You can substitue -E with -U & -P for a non-trusted connection)
 
 
Categories: Uncategorized

Microsoft.XMLHTTP to the rescue

Following up on my previous post regarding forwarding a user to a different page whilst another page is loading. I came up with a solution.
 
If you are loading a page from http://localhost, you cannot simultaneously load a page from localhost in the same session. This, I guess is a browser quirk, but nonetheless, it effects both IE and Firefox. However, you can load a page from http://127.0.0.1 – even though they’re the same server.
 
In the particular applcation I was working on, it was not acceptable to change domains, since the referer would change. Therefore, after about 4 hours of research, I read up on XMLHTTP – a technology used for out-of-band calls – as I used earlier in a .NET chatroom application.
 
So to get right to the code – here it is:
 
function openWindow(url)
{
 var xmlhttp=false;
 /*@cc_on @*/
 /*@if (@_jscript_version >= 5)
 // JScript gives us Conditional compilation, we can cope with old IE  versions.
 // and security blocked creation of the objects.
 try {
 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
 try {
 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
 } catch (E) {
 xmlhttp = false;
 }
 }
 @end @*/
 if (!xmlhttp && typeof XMLHttpRequest!=’undefined’)
 {
  xmlhttp = new XMLHttpRequest();                                           
 } 
 
 try
 {                  
  xmlhttp.open("GET", "http://<alternative URL>/" + url,true);
  win=window.open();
  xmlhttp.onreadystatechange=function()
  {                  
   if (xmlhttp.readyState==4)
   {                    
    win.document.write(xmlhttp.responseText);                 
   }
  }
  xmlhttp.send(null)  
 }
 catch(e2)
 {
  // The browser doesn’t support XMLHTTP.
  window.open(url);
 }
}   
 
Categories: Uncategorized

Help!. Can’t reopen a page whilst another is loading…

If a page takes a long time to load, but has already flushed out content containing a hyperlink, that
hyperlink will not work until the page is fully loaded.
 
To demonstrate:
 
<a href="tempTest.aspx" target="_blank">Click to reopen this page</a><br>
<%
 for (int i=0;i<1000;i++)
 {
  System.Threading.Thread.Sleep(100);
  Response.Write(i + "…");
  Response.Flush();
 } 
%>
 
If you save this as tempTest.aspx, then load it in your web browser, and click on the link before
it has counted to 1000, you will see that the popup window hangs until the first page is complete.
 
Free pint of beer to whoever solves this one!
 
Categories: Uncategorized