Search | Contact | Link To Us  

      ASP.NET      

ASP.NET
Dev Environment
Web Forms
Web Controls
ADO .NET
Web User Controls
Deployment
XML Web Services
ASP.NET Feedback Form
Resources
Discussions
VB .NET
About



Advertisement


     HomeASP.NETADO .NETSystem.Data.OleDb 

System.Data.OleDb

Insert Command 

Add a Button control to the Web Forms page. Assuming you already have a connection established (refer to previous page sample) paste the following code.

Private Sub Insert_Click(ByVal sender As System.Object, ByVal e As_
System.EventArgs) Handles Insert.Click
Try
myConn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;_
Data Source=C:\sandeep\books.mdb;")
myConn.Open()
myComm = New OleDbCommand("Insert into Table1 values 'ASP.NET ',_
'McGraw Hill',192435211", myConn)
Dim sa As Integer = myComm.ExecuteNonQuery()
Response.Write("Records inserted" & " " & sa)
myConn.Close()
Catch
End Try
End Sub

Update Command

Add a Button control to the Web Forms page and paste the following code.

Private Sub Update_Click(ByVal sender As System.Object, ByVal e As_
System.EventArgs) Handles Update.Click
Try
myConn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;_
Data Source=C:\sandeep\books.mdb;")
myConn.Open()
myComm = New OleDbCommand("Update Table1 Set Publisher='MSR'_
where publisher='McGraw Hill'", myConn)
Dim sa As Integer = myComm.ExecuteNonQuery()
Response.Write("Records updated" & " " & sa)
Catch
End Try
End Sub

Delete Command

Add a Button control to the Web Forms page and paste the following code.

Private Sub Delete_Click(ByVal sender As System.Object, ByVal e As_
System.EventArgs) Handles Delete.Click
Try
myConn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;_
Data Source=C:\sandeep\books.mdb;")
myConn.Open()
myComm = New OleDbCommand("Delete from Table1 where isbn=192435211", myConn)
Dim sa As Integer = myComm.ExecuteNonQuery()
Response.Write("Records deleted" & " " & sa)
Catch
End Try
End Sub








  Privacy Policy | Terms of Use | Site Map | Contact

  © 2004-2010 Startvbdotnet.com. All rights reserved.