Deleting rows in Excel

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2007
Posts: 169
Reputation: tuse is an unknown quantity at this point 
Solved Threads: 14
tuse's Avatar
tuse tuse is offline Offline
Junior Poster

Deleting rows in Excel

 
0
  #1
Nov 16th, 2008
Hi!

I have the following code-

  1.  
  2.  
  3. Imports System.Data.OleDb
  4. Public Class Form1
  5. Dim x As String = """"
  6. 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 & ";"
  7.  
  8. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  9.  
  10. Dim cn As New OleDb.OleDbConnection(cs)
  11.  
  12. Try
  13. cn.Open()
  14.  
  15. Catch ex As Exception
  16. MsgBox(ex.Message)
  17. End Try
  18.  
  19.  
  20. Dim cmd As New OleDbCommand("Select * from [sheet1$]", cn)
  21. Dim dr As OleDbDataReader
  22. dr = cmd.ExecuteReader
  23.  
  24.  
  25. While dr.Read
  26. Dim email As String = dr(1).ToString
  27. Try
  28. If email = "" Then
  29. Dim name As String = dr(0).ToString
  30.  
  31. Dim cmd2 As New OleDbCommand("Delete from [sheet1$] where name='" & name & "'", cn)
  32. Try
  33. cmd2.ExecuteNonQuery()
  34. 'MsgBox("means")
  35. Catch ex As Exception
  36. MsgBox(ex.Message)
  37. End Try
  38. Else
  39.  
  40. End If
  41. Catch ex As Exception
  42. MsgBox(ex.ToString)
  43. End Try
  44.  
  45. End While
  46.  
  47. MsgBox("Finally Done")
  48. End Sub
  49. 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?
My blog on .NET- http://dotnet.tekyt.info
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the VB.NET Forum
Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC