Updating Excel Spreadsheet in VB.net

Hello, I’m putting together a .net application that uses excel as its database. I’m trying to get my application update records in the excel database. I’m able to read data from the database using my application so it’s setup correctly. Can someone please assist me with this? I think the trouble I’m having is that I need to use the values from my textboxes (This is the data that will be used to update the database). But I’m not sure how to code the Comm.Command.text = Update…. Command. Please see my code below.

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles SubmitTime.Click

        Dim WEdate As String
        Dim HRworked As String
        Dim Empname2 As String
        Empname2 = EmpName.Text
        HRworked = TotalHrs.Text
        WEdate = ComboBox1.Text

        Dim Conn As New OleDbConnection
        Dim Comm As New OleDbCommand
        Conn.ConnectionString = CreateConnString("c:\Data\TimeData.xls")
        Comm.Connection = Conn
        Comm.CommandText = "Update" & WEdate & "SET HoursWorked =" & HRworked & "Where Ename = " & EmpName & ""
        Catch ex As Exception
        End Try
    End Sub

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AnthonySmithMCPAuthor Commented:
I got it working with the following statement:

Comm.CommandText = "update [TimeData$] set WeekEnding='" & TotalHrs.Text & "' where Ename = '" & EmpName.Text & "'"

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.