giovedì 28 marzo 2013
venerdì 22 marzo 2013
Conversione da Label in una DataGrid a Stringa
In .NET per convertire direttamente un oggetto, label ad esempio, a stringa, basta scrivere la seguente istruzione:
Dim Testo as String = DirectCast(myContainerControl.FindControl("lblHello"), Label).Text
martedì 12 febbraio 2013
Cancellare record duplicati oracle
DELETE FROM TABELLA1
WHERE ROWID NOT IN
(
SELECT MIN(ROWID)
FROM TABELLA1
GROUP BY CAMPO1
)
WHERE ROWID NOT IN
(
SELECT MIN(ROWID)
FROM TABELLA1
GROUP BY CAMPO1
)
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
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.
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()
Iscriviti a:
Post (Atom)