Answered truncate table by VB code

  • Wednesday, August 22, 2012 6:54 PM
     
     

    Hi All.

     I would like trancate table by click button. Is it possible trancate table thru VB code? If Yes, how it to do?

    Thanks.

All Replies

  • Wednesday, August 22, 2012 7:06 PM
     
     Answered Has Code

    Try this code

         Dim query As String = "TRUNCATE TABLE TABLENAME"
     
            Using conn As New SqlClient.SqlConnection("Connection string")
                Dim cmd As New SqlClient.SqlCommand(query, conn)
                conn.Open()
                cmd.ExecuteNonQuery()
                conn.Close()
            End Using


    Gaurav Khanna | Microsoft VB.NET MVP

  • Tuesday, September 04, 2012 9:12 AM
    Moderator
     
     

    Hi eugzl,
     
    I am marking your issue as "Answered", if you have new findings about your issue, please let me know.

     

    Best regards,


    Sheldon _Xiao[MSFT]
    MSDN Community Support | Feedback to us
    Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.