visual basic net programming march 3 2004 n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Visual Basic.NET Programming March 3, 2004 PowerPoint Presentation
Download Presentation
Visual Basic.NET Programming March 3, 2004

Loading in 2 Seconds...

play fullscreen
1 / 26

Visual Basic.NET Programming March 3, 2004 - PowerPoint PPT Presentation


  • 82 Views
  • Uploaded on

Visual Basic.NET Programming March 3, 2004. Agenda. Questions / Discussion Cookies Project Work (Ends Around 9:00 PM) Demo's (15 minutes per team). Questions. All homework homework due by Friday. Web Site will remain available for awhile, if not, contact me, I'll have the material.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Visual Basic.NET Programming March 3, 2004' - norm


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
agenda
Agenda
  • Questions / Discussion
  • Cookies
  • Project Work (Ends Around 9:00 PM)
  • Demo's (15 minutes per team)
questions
Questions
  • All homework homework due by Friday.
  • Web Site will remain available for awhile, if not, contact me, I'll have the material.
  • a tip... use the Microsoft Web Site Advanced Search to look up errors. I think it works half of the time.
cookies1
Cookies
  • Cookies are a way to save information on the client machine between web page requests.
  • A cookie is a name/value pair that the browser saves on behalf of the application.
  • Cookies are keyed to the domain of the application.
  • When a browser requests a page it automatically transmits the cookies that belong to that domain as part of the request.
  • The application then reads the cookies and takes appropriate action.
cookies2
Cookies

Cookies are generally used in two ways.

  • To save some sort of user identifying information about the user, so that when the returns to a given site, the application knows who the user is.
  • The other is to save information indicating the application's state between web page requests within a single session.

Although any information can be saved in a cookie, best practice is to use some sort of key to look up the actual information of the server.

cookies3
Cookies

Cookies are created by adding items to the Cookies collection of the ASP.NET Response object (available through the Response property of the Page Class).

Example

Dim cookie as HttpCookie

cookie = New HttpCookie("MyCookie","MyCookieValue")

Response.Cookies.Add(cookie)

cookies4
Cookies

Cookies are read from the Cookies collection of the ASP.NET Request object (available through the Request property of the Page Class).

Example

Dim cookie as HttpCookie

cookie = Request.Cookies("MyCookie")

Label1.Text = cookie.Value

httpcookie properties
HttpCookie Properties
  • Domain – the domain associated with the cookie (string).
  • Expires – date and time the cookie expires (datetime).
  • HasKeys – whether the cookie as subkeys (boolean).
  • Item – old ASP way of accessing subkeys, indexed by subkey name.
  • Name – the name of the cookie (string).
  • Path – the path associated with the cookie (string).
  • Secure – does the cookies require a secure transmission (boolean).
  • Value – the value of the cookie (string).
  • Values – if the cookie as subkeys, Values represents an instance of a NameValuesCollection.
slide13

Console Application

Command Window

Console Application

slide14

Windows Form Application

Input Screen

Windows Form Class

slide15

Windows Form with Class DLL

Input Screen

Class

Constructors

Fields

Windows Form Class

Get Set Properties

Methods

slide16

Windows Form, Class DLL, and ADO

Class

Input Screen

Constructors

Fields

Get Set Properties

Windows Form Class

Methods

Database

slide17

WebForm Application

Browser (IE6)

WebForm Class

Code Behind File

slide18

WebForm, Class DLL, and ADO

Class

Browser (IE6)

Constructors

Fields

Get Set Properties

WebForm Class

Methods

Database

Code Behind File

slide19

Web Services using localhost

Class

Browser (IE6)

Constructors

Fields

Get Set Properties

SOAP

WebForm Class

Web Service

Proxy

Methods

Database

Code Behind File

slide20

Web Services using Remote Host

Client

Server

Class

Browser (IE6)

Constructors

Fields

Get Set Properties

SOAP

WebForm Class

Web Service

Proxy

Methods

Database

Code Behind File

web form client
Web Form Client

Private Sub Button1_Click(ByVal sender As System.Object,

ByVal e As System.EventArgs) Handles Button1.Click

Label1.text = ""

Try

Dim obj As New Service1

Dim ds As New DataSet

Dim str As String = "Select * from NameAddress"

ds = obj.ServiceGetDataSet(str)

DataGrid1.DataSource = ds

DataGrid1.DataBind()

Catch ex As Exception

Label1.text = ex.Message

End Try

End Sub

web service
Web Service

<WebMethod()> _

Public Function ServiceGetDataSet(ByVal SQLStmt As String) As DataSet

Try

Dim obj As New CDatabase

Dim ds As New DataSet

obj.SQLString = SQLStmt

If obj.GetDataSet(ds) Then

Return ds

End If

Catch ex As Exception

Dim se As New SoapException("Fault occurred - " + ex.Message,

SoapException.ClientFaultCode)

Throw se

End Try

End Function

database class notes
Database Class Notes
  • Don't name everything DatabaseClass
  • Name the Project  DatabaseClass
  • Name the .vb module  DBClass
  • Name the class  Cdatabase
  • Check the project properties to determine the imports name to use in the application
database class
Database Class

Private cn As New OleDbConnection()

Private adpt As New OleDbDataAdapter()

Private m_SQLString As String

Public Sub New()

End Sub

Public Property SQLString()

Get

Return m_SQLString

End Get

Set(ByVal Value)

m_SQLString = Value

End Set

End Property

database class1
Database Class

Public Function GetDataSet(ByVal ds As DataSet) As Boolean

Try

If Not OpenConnection() Then

Throw New ApplicationException("Connection Open Failure")

End If

adpt = New OleDbDataAdapter(m_SQLString, cn)

adpt.Fill(ds, "Messages")

adpt.Dispose()

Catch ex As Exception

Throw New ApplicationException("Database Error - " + ex.Message)

Finally

cn.Close()

cn = Nothing

End Try

Return True

End Function

database class2
Database Class

Private Function OpenConnection() As Boolean

Try

If cn.State <> ConnectionState.Open Then

cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _

"Data Source=C:\...\Guestbook.mdb"

cn.Open()

Return True

End If

Catch ex As Exception

Throw New ApplicationException("Connection Failure - " + ex.Message)

End Try

End Function