Through finding the row cells I want to update my database with this information. At the moment I am assigning the excel file to a datagridview because I do not have the knowledge to find another solution after looking across the internet I still ain't come up with a suitable solution.
Upon running my code below; after one minute it crashes with the following error:
"The CLR has been unable to transition from COM context 0x94cc80 to COM context 0x94cdf0 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations."
The code below is what I'm using atm (which crashes) but I want to be able to actually get rid of the datagridview as this application must not contain a GUI (ment to be a fully automated system, with no actions taken from the end user other than running the application.
Any help would be appreciated as I've been working on this for quite some time now can cannot get it to work.
Thank you in advanced x

Email me if need be

Try 'declare a oledb connection to connect to the excel file Dim MyConnection As System.Data.OleDb.OleDbConnection 'declare a dataset Dim DtSet As System.Data.DataSet 'declare a oledb command Dim MyCommand As System.Data.OleDb.OleDbDataAdapter 'give the connection its string value MyConnection = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source='C:\AvailabilityImports\Fisher\Availability.xls';Extended Properties=Excel 8.0;") 'give the command its SQL query MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [Availability$]", MyConnection) '*** need the values in an array??? MyCommand.TableMappings.Add("Table", "TestTable") DtSet = New System.Data.DataSet MyCommand.Fill(DtSet) DataGridView1.DataSource = DtSet.Tables(0) MyConnection.Close() Catch ex As Exception MsgBox(ex.Message) End Try '*** Import captured data into SQL Database Try 'Connection String ConnectDB.ConnectionString = "Data Source=wd-00126;Initial Catalog=NewTredzWeb;Integrated Security=True" 'Show progress bar & assign its value ProgressBar1.Visible = True ProgressBar1.Maximum = DataGridView1.Rows.Count - 1 'loop through the datagridview For m = 0 To DataGridView1.Rows.Count - 1 'Update as new command Dim updateSQL As New SqlCommand 'Update command String updateSQL.CommandText = ("UPDATE tblproductsku SET SuppAvail = '" & DataGridView1.Rows(m).Cells(17).Value & "', RRP = '" & DataGridView1.Rows(m).Cells(7).Value & "', SkuTrade = '" & DataGridView1.Rows(m).Cells(9).Value & "', SuppAvailLastUpdate = GETDATE() WHERE productref in (SELECT productref FROM tblproductdetail WHERE Supplier LIKE '" & "Fisher".ToLower.Trim & "') and ManRef = '" & DataGridView1.Rows(m).Cells(2).Value & "')") 'Open connection updateSQL.Connection = ConnectDB ConnectDB.Open() 'Execute updateSQL.ExecuteNonQuery() 'Close Connection ConnectDB.Close() 'Progress bar - new value ProgressBar1.Value = m 'loop again until end of rows Next m Catch ex As Exception MessageBox.Show(ex.Message + " Update Stock for Supplier: 'Fisher' Failed") ConnectDB.Close() Finally MessageBox.Show("Successfully Inserted .XLS file into the Database") End Try End Sub