struggling to conbine a excel read into a write to data table both work seperatly in demo form but wont work together
effectively the excel document reads fine and populates the table and datagridview and the columns in datagrid matches the spreadsheet fields exactly and the table im trying to send data too but when i try and import the data table to the actual access table doesnt write
Many thanks i appeciate the help and sorry troubke you
effectively the excel document reads fine and populates the table and datagridview and the columns in datagrid matches the spreadsheet fields exactly and the table im trying to send data too but when i try and import the data table to the actual access table doesnt write
Dim table As New DataTable Dim adapter As New OleDbDataAdapter("SELECT * FROM dp2", "Provider=Microsoft.Jet.OLEDB.4.0; Data source ='" & dbpath1 & "'; Jet OLEDB:database password=123") Dim builder As New OleDbCommandBuilder(adapter) Dim ds1 As New DataSet Dim _filename As String = "C:\Users\Colin\Downloads\software\AccessConnection\DataImport.xls" Dim _conn As String Dim da As OleDbDataAdapter = New OleDbDataAdapter() Dim _command As OleDbCommand = New OleDbCommand() _conn = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & _filename & ";" & "Extended Properties=Excel 8.0;" Dim _connection As OleDbConnection = New OleDbConnection(_conn) _command.Connection = _connection _command.CommandText = "SELECT * FROM [Sheet1$]" da.SelectCommand = _command Try da.Fill(ds1, "sheet1") MessageBox.Show("The import is complete!") Me.DataGridView1.DataSource = ds1 Me.DataGridView1.DataMember = "Sheet1" BindingSource1.DataSource = DataGridView1.DataSource DataGridView1.DataSource = Me.BindingSource1 BindingSource1.EndEdit() adapter.Update(table)
Many thanks i appeciate the help and sorry troubke you
Last edited: