A simple code to delete the records from the MS ACCESS database. I have use a textbox to get the id or name of the record to delete and a delete button to perform deletion.
1)Import files
Imports System
Imports System.Data
Imports System.Data.OleDb
2)Declare variable and objects
Dim strConn As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & Server.MapPath("~/App_Data/db2.mdb") & ";"
Dim conn As OleDb.OleDbConnection
Dim cmd As OleDb.OleDbCommand
Dim rdr As OleDb.OleDbDataReader
Dim strsql As String
2)In delete button write down
Dim ssql As String = "delete from stud where (Rollno ='" & TextBox1.Text & "')"
MsgBox(ssql)
conn.Open()
Dim comm As New OleDbCommand(ssql, conn)
comm.ExecuteNonQuery()
MsgBox("record is delete")
Response.Redirect("~/Default.aspx")
conn.Close()
Thats it.......
Search
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment