ExpertRating - Online Certification and Employment Testing ExpertRating - Online Certification and Employment Testing ExpertRating - Online Certification and Employment Testing

ExpertRating Home
ExpertRating Benefits
Recommend ExpertRating
Suggest More Tests
Privacy Policy
FAQ
Login
 
ASP Dot Net Tutorial - Index
ASP Dot Net Tutorial - Microsofts ASP.NET
ASP Dot Net Tutorial - Begining Web Forms
ASP Dot Net Tutorial - User Controls
ASP Dot Net Tutorial - ADO .NET
ASP Dot Net Tutorial - DataBinding to WebControls
ASP Dot Net Tutorial - DataList Controls
ASP Dot Net Tutorial - DataGrid Control
ASP Dot Net Tutorial - Advance Practical Examples on DataGrid
ASP Dot Net Tutorial - Working with DataSets
ASP Dot Net Tutorial - Working with XML
ASP Dot Net Tutorial - Forms Based Authentication
ASP Dot Net Tutorial - Windows Based Authentication
     

 
Online Personal Trainer Certification
Test Search by Job Title
Find a Personal Trainer
Job Resources
Free Self Tests and Quizzes
Find a Lawyer
Project Management Certification
Six Sigma Certification
Six Sigma Black Belt Certification
Six Sigma Green Belt Certification
Lean Management Certification
First Aid Certification
CPR Certification
Yoga Certification
Aerobics Certification
Pilates Certification
SEO Certification
Online Photography Course & Certification
Online Business Writing Course & Certification
Baby Sitting Course & Certification
Time Manangement Certification
Health Club Management Certification
Selling Skills Certification
Business Analysis Course
Green Living Course  free!
Master Trainer Certification
Total Quality Management Certification
Kaizen Certification
Creative Writing Certification
  All Online Courses
   

   
   
   
   
   
   

   
  Home > Courses, Tutorials & eBooks > ASP.NET Tutorial > ADO.NET
 

ASP.NET Tutorial - ADO.NET

                                                                                                               Page 8 of 14
 

The output of this example is as shown below:

In the above example there are two TextBox controls named txtbookName and txtAuthor. When the Add Books! Button, are clicked the Button Click subroutine is executed, and the values entered into the two TextBox controls are inserted into the Books table of Northwind database.

Example 28 demonstrates how you can add a new record to a Microsoft Access database table using classes from the System.Data.OleDb namespace.

Example 28 OleDbParameterInsert.aspx

<%@ Import Namespace="System.Data" %>

<%@ Import Namespace="System.Data.OleDb" %>

<Script Runat="Server">

Sub Button_Click (s as Object, e As EventArgs)

Dim conNorthwind As OleDbConnection

Dim strInsert As String

Dim cmdInsert As OleDbCommand

conNorthwind = New OleDbConnection( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=c:\Books.mdb")

strInsert = "Insert into Books ( bookName, Author ) Values ( @bkName, @bkAuthor )"

cmdInsert = New OleDbCommand( strInsert, conNorthwind )

cmdInsert.Parameters.Add( "@bkName", txtbookName.Text )

cmdInsert.Parameters.Add( "@bkAuthor",txtAuthor.Text)

conNorthwind. Open ()

cmdINsert. ExecuteNonQuery ()

conNorthwind. Close ()

End Sub

</Script>

<html>

<body>

<form Runat="Server">

<h3>Add New Book Form</h3>

<b>Book's Name:</b>

<br>

<asp:TextBox

ID="txtbookName"

Runat="Server" />

<p>

<b>Author:</b>

<br>

<asp:TextBox

ID="txtAuthor"

Runat="Server" />

<p>

<asp:Button

Text="Add Books!"

OnClick="Button_Click"

Runat="Server" />

</form>

</body>

</html>

 

 

 

The output of this example is shown as below:

       

 

.

 
     
Home  |  About Us  |  Privacy Policy  |  Site Map  |  FAQs  |  Contact Us
 
© ExpertRating 2006. All Rights Reserved.