Archive

Author Archive

Serving Google Earth Links from a website

If you want to automatically load a location in Google Earth from a website, here are the steps…
 
Write an ASPX page like this:
<kml xmlns="http://earth.google.com/kml/2.0">
<Placemark>
  <description>Whatever</description>
  <name><%=strName%></name>
  <address><%= strAddress %></address>
</Placemark>
</kml>
 
The code behind is:

public string strName = "";

public string strAddress = "";

private void Page_Load(object sender, System.EventArgs e)

{

   Response.ContentType="application/earthviewer";

   strName="name..";

   strAddress="Address…";

}

 
Then add an application mapping into IIS by pressing website > Properties > Configuration > Add
 
Executable: C:WINDOWSMicrosoft.NETFrameworkv1.1.4322aspnet_isapi.dll
Extension: KML
 
Then Add the following into the web.config
 

<system.web>

<

httpHandlers>

<add verb="GET, HEAD, POST, DEBUG" path="*.kml" type="System.Web.UI.PageHandlerFactory"></add>

</httpHandlers>

</system.web>

 
Now rename the ASPX file to a .KML file, and it can be called from a browser
 
Categories: Uncategorized

Sms-txt.co.uk

Categories: Uncategorized

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

Categories: Uncategorized

Nokia 3210 opening instructions

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

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