Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Passing an Access wildcard from VB.Net 2005

Passing an Access wildcard from VB.Net 2005

Scheduled Pinned Locked Moved Visual Basic
databasecsharphelpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    CCG3
    wrote on last edited by
    #1

    I am working wiht VB.Net 2005 and I am looking at an Access 2003 database. I can run a Delte query in Access and it works fine. But when I try to run the same query from my program it doesn't delete anything. Can someone tell me what I doing wrong? Thanks so much for your help with this.... Cursor = System.Windows.Forms.Cursors.WaitCursor 'Build SQL to delete this department Dim TempDepartNum As String = Me.txtDepartNum.Text Dim Sql As String = String.Empty 'initialize database connection Dim Connection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Databases\Converted to 2003\C022008.mdb") 'set up SQL command to delete records 'DELETE SHACT.ActAcct, *FROM(SHACT) WHERE (((SHACT.ActAcct) Like '100*')); Sql = "DELETE * FROM SHACT WHERE (((SHACT.ActAcct) Like '100*'));" Try 'connect to the database and delete the records Connection.Open() Dim Command As New OleDbCommand(Sql, Connection) Command.ExecuteNonQuery() MessageBox.Show("Delete Department function completed successfully.", "Delete", MessageBoxButtons.OK)

    B 1 Reply Last reply
    0
    • C CCG3

      I am working wiht VB.Net 2005 and I am looking at an Access 2003 database. I can run a Delte query in Access and it works fine. But when I try to run the same query from my program it doesn't delete anything. Can someone tell me what I doing wrong? Thanks so much for your help with this.... Cursor = System.Windows.Forms.Cursors.WaitCursor 'Build SQL to delete this department Dim TempDepartNum As String = Me.txtDepartNum.Text Dim Sql As String = String.Empty 'initialize database connection Dim Connection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Databases\Converted to 2003\C022008.mdb") 'set up SQL command to delete records 'DELETE SHACT.ActAcct, *FROM(SHACT) WHERE (((SHACT.ActAcct) Like '100*')); Sql = "DELETE * FROM SHACT WHERE (((SHACT.ActAcct) Like '100*'));" Try 'connect to the database and delete the records Connection.Open() Dim Command As New OleDbCommand(Sql, Connection) Command.ExecuteNonQuery() MessageBox.Show("Delete Department function completed successfully.", "Delete", MessageBoxButtons.OK)

      B Offline
      B Offline
      BDEz Member 3919223
      wrote on last edited by
      #2

      Try changing the wild card * in your LIKE statement to a % see if that works. IE: Like '100*')); changes to Like '100%'));

      C 1 Reply Last reply
      0
      • B BDEz Member 3919223

        Try changing the wild card * in your LIKE statement to a % see if that works. IE: Like '100*')); changes to Like '100%'));

        C Offline
        C Offline
        CCG3
        wrote on last edited by
        #3

        Thanks, that is exactly what I needed!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups