well i need the codes for a delete button so that i can delete a record permanenltly from my login database. i connected my form to my database using the data form wizard. am constructing only a simple program. no sql statements.
thanks
please help

Member Avatar for iamthwee

>well i need the codes for a delete button so that i can delete a record permanenltly from my login ... no sql statements.

Erm, how do you intend to delete an entry from the database without using some kind of SQL statement?

well i newbie to vb.net. i have a login table in a database. i have to change username and password. as i said i already connected the database to the change password from. but i do not know how to write the codes for the delete button. well help me with watever u can please
thanks a lot

well i newbie to vb.net. i have a login table in a database. i have to change username and password. as i said i already connected the database to the change password from. but i do not know how to write the codes for the delete button. well help me with watever u can please
thanks a lot

Well i guess you do have to use a sql statement.. Well why dont use pass a sql query when your delete button is clicked..

Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
' This sub is used to delete the product record from the database
' when the user clicks the delete button
Dim cnSQL As SqlConnection
Dim cmSQL As SqlCommand
Dim strSQL As String
Dim intRowsAffected As Integer
Try
' Build Delete statement to delete the current product from table
strSQL = "DELETE FROM Products " & _
"WHERE ProductID = " & CInt(txtProductID.Text)
cnSQL = New SqlConnection(ConnectionString)
cnSQL.Open()
cmSQL = New SqlCommand(strSQL, cnSQL)
intRowsAffected = cmSQL.ExecuteNonQuery()
If intRowsAffected <> 1 Then
MsgBox("Delete Failed. Product ID " & txtProductID.Text & _
" not found.", MsgBoxStyle.Critical, "Delete")
End If
' Close and Clean up objects
cnSQL.Close()
cmSQL.Dispose()
cnSQL.Dispose()
PopulateProductList()
Catch e As SqlException
MsgBox(e.Message, MsgBoxStyle.Critical, "SQL Error")
Catch e As Exception
MsgBox(e.Message, MsgBoxStyle.Critical, "General Error")
End Try
End Sub

well dont paste the exact code that ive given.. Change the query according to your need. Hope this helps. :cool:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.