danorme
asked on
Deleting record from SQL
I have a program that allows employees to upload and delete files from a shared drive. I got the upload to work 100% and the delete to work 50%.
The files are listed in a VB listbox which are stored in SQL.
My delete process does delete the file from the shared drive, but does not delete the record from SQL. Here is my code THAT DOES NOT WORK.
Dim sSQL As String
Dim conn As SqlConnection = New SqlConnection("integrated security=SSPI;data source=SERVERNAME;persist security info=False;initial catalog=DATABASE")
Dim comm As New SqlCommand
sSQL = "DELETE * FROM loanfiles WHERE ([lnfile]=" & (lstUploadedFiles.Text) & ");"
comm.Connection = conn
comm.CommandText = sSQL
conn.Open()
comm.ExecuteNonQuery()
conn.Close()
I am getting a syntax error on comm.ExecuteNonQuery()
This is urgent. Please help.
The files are listed in a VB listbox which are stored in SQL.
My delete process does delete the file from the shared drive, but does not delete the record from SQL. Here is my code THAT DOES NOT WORK.
Dim sSQL As String
Dim conn As SqlConnection = New SqlConnection("integrated security=SSPI;data source=SERVERNAME;persist security info=False;initial catalog=DATABASE")
Dim comm As New SqlCommand
sSQL = "DELETE * FROM loanfiles WHERE ([lnfile]=" & (lstUploadedFiles.Text) & ");"
comm.Connection = conn
comm.CommandText = sSQL
conn.Open()
comm.ExecuteNonQuery()
conn.Close()
I am getting a syntax error on comm.ExecuteNonQuery()
This is urgent. Please help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Oh yeah. I totally overlooked that. You also don't require the parentheses or the semicolon.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
PERFECT!!!!!!