i have my access database document already inserted and i wa

i have my access database document already inserted, and i want to link the search, save , Delete buttons to it. so that i would be able to record to my database document and to delete from it and search from it . what codes do i need to write behind each of those buttons to make it work . and please be very detail.
note : i am using access database document (OLEDb).
and if there is connection string, how do i connect the string ?

Solution

Imports System.Data

Imports System.Data.OledDb

public class form1

Dim cnnOLEDB As New OleDbConnection

Dim cnnOLEDB As New oleDbCommand

Dim cnnInsert As New oleDbCommand

Dim cnnUpdate As New oleDbCommand

Dim cnnDelete As New oleDbCommand

Dim strconnectionString=\"Provider=microsoft.jet.OLEDB.4.0;Data Source=\"System.Environment.CurrentDirectory&\"\\TestDB.mdb\"

Private Sub Form1_Load(ByVal sender As System.Object,ByVal e As System.EvenArgs)handles MyBase.Load

cnnOLEDB.ConnectionString=strConnectionString

cnnOLEDB.Open()

End Sub

private Sub btnSearch_Click(ByVal sender As System.object,Byval e As System.EventArgs)Handles btnSearch.Click

textAearchResult.Text=\"\"

Dim vSearch As String=inputBox(\"Enter integer number to search name\")

If vSearch<>\"\"\"Then

cmdOLEDB.CommandText=\"Select Au_ID,Author FROM Authors WHERE Au_ID=\" & CInt(vSearch)

cmdOLEDB.Connection=cnnOLEDB

Dim rdrOLEDB As OledbDataReader=cmd.OLEDB.ExecuteReader

If rdrOLEDB As OledbDataReader = cmdOLEDB.ExecuteReader

If rdrOLEDB.Read=True Then

txtAearchResult.Text &

=rdrOLED.Item(0).ToString&\" \"&

rdrOLEDB.Item(1).ToString

rdrOLEDB.Close()

Exit Sub

Else

MsgBox(rdrOLEDB.Close()

\"Record not found\")

Exit Sub

End If

Else

msgbox( \"Enter serach value\")

Exit Sub

End if

End Sub

Private Sub btnInsert_click(By Val sender As System.object, ByVal e As System.EventArgs)Handles btnlinser.Click

If txtAu_Id.Text<>\"\"And textAuthor.text<>\"Then)

cmdInsert.Command.Text=\"insert into authors(Au_id,Author)values( xtau_id.Text&\"\"\",txtauthor.Text&

MsgBox(cmdInsert.commandText)

cmdInsert.commandType=CommandType.Text

cmdInssert.Connection=cnnOLEDB

cmdinsert.ExecuteQuery()

msgBox(txtAu_id.text=\"Record Inserted\")

txtAuthor.text=\"\"

Else

MsgBox(\"Enter the required values)

End If

cmdInsert.Dispose()

End sub

private Sub btnUpdate_Click(byVal Sender As System.Object,By val e As System.EventArgs)Handles btnUpdate.Click

if txtAu_Id<> And txtAuthor.Txt<>\"\"then

cmdUpdate.CommandTxt=\"UPDATE AUTHORS SET Author=\"txtAutor.Txt&\"Where Au_Id=&txtAu_Id.Text&\"

MsgBox(cmdUpdate.Commandtxt)

cmdUpdate.C\\ommandtype=CommandType.text

cmdUPDATE.Connection=cnnOLEDB

cmdUPDATE.executeNonquery()

MsgBox(txtAu_id.txt=\"record updated)\"

txtAuthor.text=\"\"

else

MsgBox(\"enter requied values\")

end if

cmdupdate.Dispose()

Private Sub btnDelete_click(By Val sender As System.object, ByVal e As System.EventArgs)Handles btnDelete.Click

If txtAu_Id.Text<>\"\"And textAuthor.text<>\"Then)

cmdDeleteCommand.Text=\"DELETE FROM Authors(Au_id,Author)values( xtau_id.Text&\"\"\",txtauthor.Text&

MsgBox(cmdDelete.CommandText)

cmdDelete.commandType=CommandType.Text

cmdDelete.Connection=cnnOLEDB

cmdDelete.ExecuteNonQuery()

msgBox(txtAu_id.text=\"Record deleted\")

txtAuthor.text=\"\"

cmdDelete.Dispose()

Else

MsgBox(\"Enter the required values)

End If

cmdUpdate.Dispose()

End sub

End Class

 i have my access database document already inserted, and i want to link the search, save , Delete buttons to it. so that i would be able to record to my databa
 i have my access database document already inserted, and i want to link the search, save , Delete buttons to it. so that i would be able to record to my databa
 i have my access database document already inserted, and i want to link the search, save , Delete buttons to it. so that i would be able to record to my databa

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site