Hi,
I developed a .Net Application and on my laptop had Microsoft Excel2003 installed and it worked fine.
I have an excel connection as shown;
on a click event I have the follwoing code called;
Now this workd perfectly, until Microsoft Office Proffesional Plus 2010 was upgraded to my laptop.
Whenever, am trying to load patients I receive the message - "File format is invalid".
When I check the format it is NOT Invalid.
As I test, I took a colleague laptop with Excel2003 the file was uploaded successfully.
Therefore, I changed my connection in Excel to
I still receive the same message - File format is Invalid.
Please help
Thanks
I developed a .Net Application and on my laptop had Microsoft Excel2003 installed and it worked fine.
I have an excel connection as shown;
Code:
Namespace ExcelConnectionGPRD
Public Class ExcelConnectionGPRD
#Region "Public Function(s)"
Public Function ImportAttendence(ByVal PrmPathExcelFile As String, ByVal dgvImportData As DataGridView)
Dim MyConnection As System.Data.OleDb.OleDbConnection
Try
''''''' Fetch Data from Excel
Dim DtSet As System.Data.DataSet
Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
MyConnection = New System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; " & _
"data source='" & PrmPathExcelFile & " '; " & "Extended Properties=Excel 8.0;")
' Select the data from Sheet1 of the workbook.
MyCommand = New System.Data.OleDb.OleDbDataAdapter("select GoldPatID from [sheet1$]", MyConnection)
MyCommand.TableMappings.Add("Table", "Attendence")
DtSet = New System.Data.DataSet
MyCommand.Fill(DtSet)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
dgvImportData.DataSource = DtSet.Tables(0)
MyConnection.Close()
Catch ex As Exception
MyConnection.Close()
End Try
End Function
#End Region
End Class
End Namespace
Code:
Private Sub GPRD_import_pat_eid()
Try
Dim _Obj As New ExcelConnectionGPRD.ExcelConnectionGPRD
_Obj.ImportAttendence(FrmProjectSetup.Txt_Path.Text, FrmProjectSetup.dgvImportData_pateid)
Me.Close()
If FrmProjectSetup.dgvImportData_pateid.RowCount > 0 Then
FrmProjectSetup.BtnExportPateid.Visible = False
FrmProjectSetup.BtnExportGPRDPatID.Visible = True
FrmProjectSetup.btnGPRDExport.Visible = False
FrmProjectSetup.btnExport.Visible = False
FrmProjectSetup.BtnExportPateid_fneventdt.Visible = False
FrmProjectSetup.BtnExportGLDPatID_fneventdt.Visible = False
MsgBox("Data imported successfully", MsgBoxStyle.Information, "VeriSIS")
Else
MsgBox("File format is invalid", MsgBoxStyle.Information, "VeriSIS")
End If
Catch ex As Exception
End Try
End Sub
Whenever, am trying to load patients I receive the message - "File format is invalid".
When I check the format it is NOT Invalid.
As I test, I took a colleague laptop with Excel2003 the file was uploaded successfully.
Therefore, I changed my connection in Excel to
Code:
MyConnection = New System.Data.OleDb.OleDbConnection("provider=Microsoft.ACE.OLEDB.12.0; " & _
"data source='" & PrmPathExcelFile & " '; " & "Extended Properties=Excel 12.0 Xml; HDR=YES;")
Please help
Thanks