[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 431
  • Last Modified:

VB.Net SQL DELETE * FROM Error

Experts, I am trying to delete all of the data rows in the SQL table but am getting this error on the follow line:

Code line that error occurs:
myCommand.ExecuteNonQuery()

Error message:
"SQLException was unhandled...Incorrect syntax near '*'."

FYI I have confirmed all of the variables and connection string are working correctly.

Thank you very much for you help!!


'DELETE NULL DATA PLACE HOLDERS PRIOR TO IMPORT
        If Conn.State = ConnectionState.Open Then
            Conn.Close()
            Conn.Open()
        Else : Conn.Open()
        End If
        Dim strSQL As String = ("USE " & DBName & ";DELETE * FROM " & moduletableCB.Text & ";")
        Dim myCommand As New SqlCommand(strSQL, Conn)
        myCommand.ExecuteNonQuery()
        If Conn.State = ConnectionState.Open Then
            Conn.Close()
        End If

Open in new window

0
adamchicago
Asked:
adamchicago
1 Solution
 
Aneesh RetnakaranDatabase AdministratorCommented:
>DELETE * FROM

it shoul be

DELETE  FROM
0
 
Kamaraj SubramanianApplication Support AnalystCommented:
try to change this
  Dim strSQL As String = "USE " & DBName & ";DELETE * FROM " & moduletableCB.Text & ";"

Open in new window

0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
you must remove the *, and even might remove the FROM ...

0
 
adamchicagoAuthor Commented:
Thank you
0

Featured Post

Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now