Posts Tagged ‘Datatable’
Export to Excel with error Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046}
Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154.
This error occurs when the Microsoft office has not installed in the target machine.
You can export the file to csv.
Specified cast is not valid in WriteXml using Dataset
This exception appears when using WriteXml of datatable or dataset. This is also caused by when you create a datatable manually and you set the “defaultvalue” to one or more datacolumn. Remove the “defaultvalue” and it will be fine.
For more information on setting defaultvalue click here
How to Select Records in the Datatable
To select records/items in the datatable;
-
-
Sub FilterData(dt as DataTable)
-
Dim dRow() as Datarow
-
-
dRow = dt.select("CustomerID=10" )
-
-
Console.WriteLine("Rows " & dRow.Length)
-
-
-
End Sub
How to return the Last Inserted ID in Datatable
Public Function AddToSubGroupTable(ByVal ParentID As Int32, ByVal masterID As Int32, ByVal FieldName As String, ByVal fieldAlias As String, ByVal Value As String, ByVal ValueText As String) As Long
Try
Dim dr As DataRow
With dtSubGroup.Rows
dr = dtSubGroup.NewRow
dr(“ParentID”) = ParentID
dr(“FieldName”) = FieldName
dr(“MasterFileID”) = masterID
dr(“Fieldalias”) = fieldAlias
dr(“Value”) = Value
dr(“ValueText”) = ValueText
.Add(dr)
End With
dtSubGroup.AcceptChanges()
Return dr(“PKID”).ToString
Catch ex As Exception
Throw New System.Exception(ex.Message, ex.InnerException)
End Try
End Function