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.

, ,

No Comments


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

, , ,

No Comments


How to Select Records in the Datatable

To select records/items in the datatable;

  1.  
  2. Sub FilterData(dt as DataTable)
  3. Dim dRow() as Datarow
  4.  
  5. dRow = dt.select("CustomerID=10" )
  6.  
  7. Console.WriteLine("Rows " & dRow.Length)
  8.  
  9.  
  10. End Sub

, , ,

No Comments


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

, ,

No Comments



SetPageWidth