|
-
Jun 9th, 2003, 11:00 PM
#1
Thread Starter
New Member
Delete Record from Database
I cannot figure out how to delete a row from a database with a VB.NET program. Basically when I have the contents of the row being shown in various textboxes and comboboxes, I want to be able to delete the row that contains that particular information by clicking a button. Can anyone help me?
-
Jun 10th, 2003, 01:55 AM
#2
Hyperactive Member
Use SQL, the DELETE statement would do it.
-
Jun 10th, 2003, 03:21 AM
#3
Sleep mode
In case you couldn't figure it out , here you go .
VB Code:
Public Sub DeleteDB(ByVal DelStr As String, ByVal TableStr As String, ByVal ColumnStr As String)
Dim SQLText As String = "DELETE FROM " & TableStr & " WHERE " & ColumnStr & " = " & " '" & DelStr & "'" & ""
Dim objCmd As New OleDb.OleDbCommand(SQLText, MyConnection)
OpenDB.OpenDB()
Try
If objCmd.ExecuteNonQuery() Then
MessageBox.Show("Data Deleted Successfully ...")
Else
MessageBox.Show("Can't delete Data")
End If
Catch ee As OleDb.OleDbException
MessageBox.Show(ee.Message)
End Try
CloseDB.CloseDB()
End Sub
-
Jun 10th, 2003, 08:46 AM
#4
Thread Starter
New Member
Where do I get the first OpenDB and CloseDB in these statements?
OpenDB.OpenDB()
CloseDB.CloseDB()
VB.net says the variables aren't declared
-
Jun 10th, 2003, 12:12 PM
#5
Sleep mode
Originally posted by chrisgeleven
Where do I get the first OpenDB and CloseDB in these statements?
OpenDB.OpenDB()
CloseDB.CloseDB()
VB.net says the variables aren't declared
Forget about that . These are routines for opening and closing connection . All what you have to do is , declare a connection obj and use it in place of OpenDB and Close that connection when you are done . Tell me if you are stuck .
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|