tuse 22 Junior Poster

Hi!

I have the following code-

Imports System.Data.OleDb
Public Class Form1
    Dim x As String = """"
    Dim cs As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\sbi\mm.xls;Extended Properties=" & x & "Excel 12.0 Xml;HDR=YES" & x & ";"

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim cn As New OleDb.OleDbConnection(cs)

        Try
            cn.Open()

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try


        Dim cmd As New OleDbCommand("Select * from [sheet1$]", cn)
        Dim dr As OleDbDataReader
        dr = cmd.ExecuteReader


        While dr.Read
            Dim email As String = dr(1).ToString
            Try
                If email = "" Then
                    Dim name As String = dr(0).ToString

                    Dim cmd2 As New OleDbCommand("Delete from [sheet1$] where name='" & name & "'", cn)
                    Try
                        cmd2.ExecuteNonQuery()
                        'MsgBox("means")
                    Catch ex As Exception
                        MsgBox(ex.Message)
                    End Try
                Else

                End If
            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try

        End While

        MsgBox("Finally Done")
    End Sub
End Class

I am trying to delete rows but I get the error-

Deleting data in a linked table is not supported by this ISAM

Anybody know how to get deletion to work in an excel sheet?