lunedì 11 febbraio 2013

Select Top 1 in Oracle

L'esempio seguente restituisce un solo valore della tabella Table1 con data più recente:

SELECT Campo1
FROM (
    SELECT Campo1,  RANK() OVER (ORDER BY DATA_ORA DESC) sal_rank
    FROM table1
    WHERE table1.id = :id
)
WHERE sal_rank = 1


mentre per far restituire gli ultimi 3 basta sostituire l'ultima riga con la seguente:

WHERE sal_rank <= 3

giovedì 3 gennaio 2013

Importare file excel da vb.net

Da VB.NET potrebbe nascere la necessità di importare un file excel, sia formato 2003 che 2007.
Dopo svariate prove, ho trovato questa libreria compatibile sia con la versione .net 2.0 che della relativa versione compact per dispositivi mobile.

http://exceldatareader.codeplex.com/

Anzitutto occorre scaricare le librerie da importare

http://exceldatareader.codeplex.com/downloads/get/80427

Dopo aver scaricato ed estratto le due dll, sarà possibile importare il file excel.


Imports ICSharpCode
Imports Excel




Dim stream As FileStream = File.Open(filePath, FileMode.Open, FileAccess.Read)

'1. Reading from a binary Excel file ('97-2003 format; *.xls)
Dim excelReader As IExcelDataReader = ExcelReaderFactory.CreateBinaryReader(stream)
'...
'2. Reading from a OpenXml Excel file (2007 format; *.xlsx)
Dim excelReader As IExcelDataReader = ExcelReaderFactory.CreateOpenXmlReader(stream)
'...
'3. DataSet - The result of each spreadsheet will be created in the result.Tables
Dim result As DataSet = excelReader.AsDataSet()
'...
'4. DataSet - Create column names from first row
excelReader.IsFirstRowAsColumnNames = True
Dim result As DataSet = excelReader.AsDataSet()

'5. Data Reader methods
While excelReader.Read()
    'excelReader.GetInt32(0);
End While

'6. Free resources (IExcelDataReader is IDisposable)
excelReader.Close()




lunedì 16 gennaio 2012

Screen shot Windows Mobile

Per chi sviluppa applicativi per windows mobile o per Android, nasce l'esigenza di realizzare un manuale utente. In tale manuale devono essere inserite anche le schermate proprie del PDA.
A tal fine viene in nostro aiuto un programma semplice e veloce MyMobiler. Con tale programma è possibile creare screen shot direttamente del PDA oppure dei video, con la possibità di salvare nella clip board, in un file grafico oppure un video.

giovedì 21 aprile 2011

ORA-12520

Al verificarsi di questo errore in Oracle XE (Express Edition), basta eseguire
la seguente riga di codice da sqlplus oppure da toad :
ALTER SYSTEM SET PROCESSES=100 SCOPE=SPFILE;

Dopo tale imputazione va riavviato il servizio oracle.

sabato 19 febbraio 2011

ReadyState vb.net infinito

La mia soluzione:

Dim dt As Date = Date.Now

Do
Application.DoEvents()
If DateDiff(DateInterval.Second, dt, Date.Now) > 30 Then
GoTo labe
End If

Loop Until WebBrowser1.ReadyState = WebBrowserReadyState.Complete


il 30 indica che se resta "bloccato" nel loop infinito dopo 30 secondi esce con il vecchio goto (ormai andato in disuso).