Public Function ListObjectToDataSet(Of T)(ByVal list As IList(Of T)) As DataSet
Dim elementType As Type
Dim ds As New DataSet()
Dim t1 As New DataTable()
Try
elementType = GetType(T)
ds.Tables.Add(t1)
'add a column to table for each public property on T
For Each propInfo In elementType.GetProperties()
Dim ColType As Type = If(Nullable.GetUnderlyingType(propInfo.PropertyType), propInfo.PropertyType)
t1.Columns.Add(propInfo.Name, ColType)
Next
'go through each property on T and add each value to the table
For Each item As T In list
Dim row As DataRow = t1.NewRow()
For Each propInfo In elementType.GetProperties()
row(propInfo.Name) = If(propInfo.GetValue(item, Nothing), DBNull.Value)
Next
t1.Rows.Add(row)
Next
Return ds
Catch ex As Exception
Return Nothing
End Try
End Function
jueves, 22 de mayo de 2014
martes, 25 de marzo de 2014
Removing leading zeros in a nvarchar sql -Remover ceros a la izquierda en un nvarchar sql
SUBSTRING(Col1, PATINDEX('%[^0 ]%', Col1 + ' '), LEN(Col1))
ejemplo
select SUBSTRING('0052658f', PATINDEX('%[^0 ]%', '0052658f' + ' '), LEN('0052658f'))
resultado
52658f
ejemplo
select SUBSTRING('0052658f', PATINDEX('%[^0 ]%', '0052658f' + ' '), LEN('0052658f'))
resultado
52658f
Suscribirse a:
Entradas (Atom)