Adding Record To Your Database - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

Adding Record To Your Database

Description:

Type and center More Movie Data: On the left side of the ... record to your Movie database. Update. You can see that your movie record has been updated ... – PowerPoint PPT presentation

Number of Views:149
Avg rating:3.0/5.0
Slides: 15
Provided by: briangs
Category:

less

Transcript and Presenter's Notes

Title: Adding Record To Your Database


1
Lesson 11
  • Adding Record To Your Database

2
Adding Records
  • Create a new page and call it AddRecords.aspx

3
Add to your workspace area
  • Type and center More Movie Data
  • On the left side of the workspace type the
    following
  • Enter Movie Name
  • Enter Actor
  • Enter Actress
  • Enter Director
  • Enter Release Date
  • Enter Rating
  • Enter MPAA
  • Enter Run Time

4
Add Textbox
  • Drag a TextBox and place it to the right of field
    names you just entered (Use Absolute Position
    found under the Layout menu for placement

5
Add a button
  • Drag a button and place in the middle

6
Label Message
  • Drag a Label and place it below the button
  • On the label properties, do the following
  • To the right of ID type labelMessage
  • Select Fore Color to be Red
  • Aside of Text Delete the word Label

7
Adding ButtonEvent Code
  • Click on Code View
  • Drag an INSERT Data Method
  • Select the Movies Database and click OK
  • Click Next and name the Method AddMovieRecord

8
Insert Code
  • Go back to Design View and double click the
    button
  • Before the End Sub type
  • Dim MovieName As String
  • Dim Actor As String
  • Dim Actress As String
  • Dim Director As String
  • Dim ReleaseDate As DateTime
  • Dim Rating As String
  • Dim MPAA As String
  • Dim RunTime As String

You have just created variables for all your
fields used in the database
9
More Code To Add
  • MovieName Server.HtmlEncode (TextBox1.Text)
  • Actor Server.HtmlEncode (TextBox2.Text)
  • Actress Server.HtmlEncode (TextBox3.Text)
  • Director Server.HtmlEncode (TextBox4.Text)
  • ReleaseDate Server.HtmlEncode (TextBox5.Text)
  • Rating Server.HtmlEncode (TextBox6.Text)
  • MPAA Server.HtmlEncode (TextBox7.Text)
  • RunTime Server.HtmlEncode (TextBox8.Text)

10
Server.HtmlEncode Coversion
  • For the variables you created you must then pass
    the information to those variables with this
    conversion
  • Remember the AddMovieRecord method you created?
    This is now going to be used in your code

11
Passing Values To Your Database
  • Continue to type this code
  • Try
  • AddMovieRecord (MovieName, Actor, Actress,
    Director, ReleaseDate, Rating, MPAA, RunTime)
  • labelMessage.Text "Your movie record has been
    updated, Thanks"
  • Button1.Enabled False
  • Catch
  • labelMessage.Text "Please submit again there was
    an error"
  • End Try

12
Error Checking Code
  • The Try-Catch block is for error checking
  • You can see the two messages that were created
    and will be displayed in entries were successful
    or unsuccessful

13
Entering Records
  • Press F5 and load the new page
  • Enter the following record to your Movie database

14
Update
  • You can see that your movie record has been
    updated successfully
  • For now you can go back to Web Matrix and click
    on data and view the updated JamesBondSeries
    Table with you your new record
Write a Comment
User Comments (0)
About PowerShow.com