Results 1 to 1 of 1

Thread: Writing to an Excel-file?

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Denmark
    Posts
    1,049

    Writing to an Excel-file?

    I have this code:

    Code:
    Sub WriteToExcel()
            Dim strCn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
            "Data Source=" & Server.MapPath("vs_test.xls") & ";" & _
            "Extended Properties=Excel 8.0;"
            Dim strSql As String = "update [Sheet1$] SET Value=55 WHERE Id=1;"
            Dim objConnection As New OleDbConnection(strCn)
            Dim objCommand As New OleDbCommand(strSql, objConnection)
            Dim objDataReader As OleDbDataReader
    
            objConnection.Open()
            objCommand = New OleDbCommand(strSql, objConnection)
            objCommand.ExecuteNonQuery()
            objConnection.Close()
        End Sub
    It says, there is an error in the UPDATE statement. I have attatched the file, that I connect to.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width