Results 1 to 3 of 3

Thread: SQL statement problem [Resolved]

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2005
    Posts
    11

    Resolved SQL statement problem [Resolved]

    This code executes than refreshes my List Box but it doesn't actually delete the record in the database. Anyone have any ideas?

    VB Code:
    1. Private Sub cmdRemove_Click()
    2.     'Deletes Current Record
    3.     If (MsgBox("Are you sure you want to delete this record?", vbYesNo + vbDefaultButton2 + vbExclamation, "Remove User") = vbYes) Then
    4. Execute fn, "DELETE FROM Users WHERE UserName = " & " 'txtUserName.Text' "
    5.         LoadUserListBox
    6.     End If
    7. End Sub
    8.  
    9. Public Sub Execute(FileName As String, SQL As String)
    10.     Dim MyConnection As New ADODB.Connection
    11.     Dim MyRecordset As New ADODB.Recordset
    12.    
    13.     MyConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & FileName
    14.     MyConnection.Mode = adModeShareDenyNone
    15.     If MyConnection.State <> adStateOpen Then
    16.         MyConnection.Open
    17.     End If
    18.     MyConnection.Execute SQL
    19. End Sub
    Last edited by jigap21; Feb 19th, 2005 at 05:16 PM.

  2. #2

    Thread Starter
    New Member
    Join Date
    Feb 2005
    Posts
    11

    Re: SQL Statement Problem

    Problem Fixed

    VB Code:
    1. Execute fn, "DELETE FROM Users WHERE UserName = '" & txtUserName.Text & "'"

  3. #3
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: SQL statement problem [Resolved]

    It looks the same to me.

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