Hi, I need your help, because the whole of today I just spent to find the solution but still can't get properly. It works well for the date >12 only
My purpose is to import excel file into Datagridview with a selection on date field before upload
My Excel file just consists of 3 columns: InvoiceNbr, InvoiceDate, UpdatedBy
I use DTP to filter the date and my DateTimePicker format is set into SHORT in property
My code for selection is:
dataset = New System.Data.DataSet
MyCommand.Fill(dataset)
DataGridView1.DataSource = dataset.Tables(0)
MyConnection.Close()
I'm trying to change CultureInfo into en-GB, but maybe it is not properly define as I'm really newbie in VB .net
This is my code for setting CultureInfo:
I think the problem comes from format en-US, but I don't know how to set in in DTP and selection
Thanks for the help in advance
My purpose is to import excel file into Datagridview with a selection on date field before upload
My Excel file just consists of 3 columns: InvoiceNbr, InvoiceDate, UpdatedBy
I use DTP to filter the date and my DateTimePicker format is set into SHORT in property
My code for selection is:
MyConnection = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source= d:\\testprint\test1.xlsx ; extended Properties= Excel 12.0;")
MyCommand = New System.Data.OleDb.OleDbDataAdapter("Select * from [Sheet1$] where InvDate = #" & DateTimePicker1.Value.ToShortDateString & "#", MyConnection)
MyCommand.TableMappings.Add("Table", "Net-informations.com")
MyCommand = New System.Data.OleDb.OleDbDataAdapter("Select * from [Sheet1$] where InvDate = #" & DateTimePicker1.Value.ToShortDateString & "#", MyConnection)
MyCommand.TableMappings.Add("Table", "Net-informations.com")
dataset = New System.Data.DataSet
MyCommand.Fill(dataset)
DataGridView1.DataSource = dataset.Tables(0)
MyConnection.Close()
I'm trying to change CultureInfo into en-GB, but maybe it is not properly define as I'm really newbie in VB .net
This is my code for setting CultureInfo:
Imports System.Globalization
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
My.Application.ChangeCulture("en-Gb")
My.Application.ChangeUICulture("en-Gb")
DateTimePicker1.Format = DateTimePickerFormat.Short
My.Application.ChangeUICulture("en-Gb")
DateTimePicker1.Format = DateTimePickerFormat.Short
End Sub
I think the problem comes from format en-US, but I don't know how to set in in DTP and selection
Thanks for the help in advance