Field not updatable??

Skuddler

New member
Joined
May 8, 2008
Messages
1
Programming Experience
Beginner
Hey everyone

I need to build an application that allows users to edit the records stored in an MS Excel spreadsheet. This happens when they click a Submit button. The record to be edited is determined by the two selected items from two drop down lists.

But I keep getting an error that says: Cannot update '(expression)'; field not updateable. I can't figure out how to proceed, and it's starting to get pretty frustrating.

This is my code:

VB.NET:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim s As String = ddlCity.SelectedItem.Text + "," + ddlProvince.SelectedItem.Text
        MsgBox(s)
        Dim xConnStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
         "Data Source=" & Server.MapPath("Response time tool.xls") & ";" & _
         "Extended Properties=Excel 8.0;"

        Dim objConn As New OleDbConnection(xConnStr)
        objConn.Open()

        'Initialize UPDATE statement and command
        Dim insComm As String = "UPDATE [Sheet3$]" & _
                                "SET [Drive1]=@Drive1, " & _
                                "[KMs1]=@NumberKM, " & _
                                "[DriveTime1]=@DriveTime, " & _
                                "[DriveZone1]=@DZ, " & _
                                "[TimeZone1]=@DTZ, " & _
                                "[Drive2]=@Drive2 " & _
                                "WHERE [CityName,Province] = 'BRAMPTON,ONTARIO'"
        Dim objInsComm As New OleDbCommand(insComm, objConn)
        'Create UPDATE parameters

        objInsComm.Parameters.Add("@Drive1", OleDb.OleDbType.VarChar)
        objInsComm.Parameters.Item("@Drive1").Value = txtClosestOffice.Text

        objInsComm.Parameters.Add("@NumberKM", OleDb.OleDbType.VarChar)
        objInsComm.Parameters.Item("@NumberKM").Value = txtNumberKM.Text

        objInsComm.Parameters.Add("@DriveTime", OleDb.OleDbType.VarChar)
        objInsComm.Parameters.Item("@DriveTime").Value = txtDriveTime.Text

        objInsComm.Parameters.Add("@DZ", OleDb.OleDbType.VarChar)
        objInsComm.Parameters.Item("@DZ").Value = txtDZ.Text

        objInsComm.Parameters.Add("@DTZ", OleDb.OleDbType.VarChar)
        objInsComm.Parameters.Item("@DTZ").Value = txtDTZ.Text

        objInsComm.Parameters.Add("@Drive2", OleDb.OleDbType.VarChar)
        objInsComm.Parameters.Item("@Drive2").Value = txtClosestOffice2.Text

        objInsComm.Parameters.Add("@CityProvince", OleDb.OleDbType.VarChar)
        objInsComm.Parameters.Item("@CityProvince").Value = s

        'Execute the query

        objInsComm.ExecuteNonQuery()
        objConn.Close()
    End Sub

Any help would be greatly appreciated :)
 
i never used Excel for a database, but I cant recommend it.

Field not updatable.. er.. the cell is read only?
 

Latest posts

Back
Top