Tuesday, August 25, 2009

continued data base

Data base


SQL = structured Query Language

There are two types of data bases flat flie and relational


insert / input
Delete
update
select are used to enter or edit information.

fields are columns and records are rows in a data base table.
SQL = structured Query Language

Dim strSQLStrings() As String = {"SELECT * FROM ApprovedTravelRequests", _
"SELECT [Travel Cost] FROM ApprovedTravelRequests", _
"SELECT [Travel Cost],Location FROM ApprovedTravelRequests", _
"SELECT * FROM ApprovedTravelRequests WHERE Location = 'Richmond, VA'", _
"SELECT * FROM ApprovedTravelRequests WHERE Location LIKE 'R%'"}

"SELECT * FROM ApprovedTravelRequests WHERE Location LIKE '%R'"}
returns anything in which you chose ie letter
"SELECT * FROM ApprovedTravelRequests WHERE Location LIKE '%A%'"}
this returns anything in which the character you chose for the range or record


"SELECT * FROM ApprovedTravelRequests WHERE Location [Last Name]LIKE '%A%'"}
'[LAST NAME] square brackets used for spaces between names
these are the conditions to evaluate whether the condition is true or not

<
>
>=
<=
<>
=


"SELECT * FROM ApprovedTravelRequests WHERE [Travel Cost] = 1000 "}
To find all costs of the feilds in the table

return feilds greater than

"SELECT * FROM ApprovedTravelRequests WHERE [Travel Cost] <= 1000 "}

return feilds less than


AND

"SELECT * FROM ApprovedTravelRequests WHERE [First Name] = 'Janet' And [Last Name] = 'Dunford'"}

OR

"SELECT * FROM ApprovedTravelRequests WHERE [First Name] = 'Janet' or [Last Name] = 'Tirrel'"}
'And is the operator that looks for both names and the or looks for either name.
"SELECT * FROM ApprovedTravelRequests WHERE [Last Name] LIKE '%LAS'"}
'%LAS ANYTHING BEFORE IT OR AFTER IT wild card character


"SELECT * FROM ApprovedTravelRequests WHERE Location = 'chicago, illinois' And [Purpose for Travel] = 'Financial Seminar'", _
"SELECT * FROM ApprovedTravelRequests WHERE Location = 'chicago, illinois' OR [Purpose for Travel] = 'Financial Seminar'"}

Data Base

Data base
Data Base There are two types of data, first is relational and the second is flat file.
Flat file is an excel data base, ie spreedsheets.
Tables in access
In tables on Data base there are a few important keys to remember,Every coloumn is a field Every row is a record,Every table has a primary key you can have only one primary key for each table,this is a unique feature key for the table.
You need to define an id field.
To find some thing you need remember Id,
ID is the king. and key to everything you need for finding what you need.

Monday, August 10, 2009

Arrays

Arrays


Dim MyVariable As DataType = x
Dim StrName As String ="rach"
DimArray (5) As DataType
DimStrNames(2) As String
StrNames(0) = "rach"
StrNames(1) = "pam"
StrNames(2) = "david"


Declare and populate an array.
This means you can use as many or as little as you like.
Dim chMenu() As char ={"a","A","b"}

Loops



Dim intDinnerBooking(2) As Integer
->Dim strNames(2) As String
->Loop to populate


0 1 2
strNames "rach" "pam" "david"







0 1 2

intDinnerBookings 4 2 3






Dim ItemArray() As String = {"x","y","z"}
Dim intCount AsInteger

'declared a count integer
length is a property
length returns the number of elements not the upperbound.



For intCount= 0 To ItemArray.Length-1
lstbox.items.add(ItemArray(0)) 'this line of code is always going to return.
also requires a number even if zero 0
lstbox.items.add(ItemArray(intCount))


intCount can be used or declared as a varible


Next
listbox

intCount= 0 x
intCount=1 y
intCount=2 z

if no -1
the loop will count 4

The data in an array is often for an organized array
telephone directory is sorted by last name making this easier to search and locate family or friends.
When the sort procedure is applied to an array the lowest value is placed in the first element in th array with an index of zero the next lowst place is placed in the 2nd array and so on until the largest value is stored in the higher element of the array.

Dim intAges() as Integer ={16, 64, 41, 8, 19, 81, 23}
Array sort(intAges)


Binary search goes to the middle and starts search in the middle.
sort array
Sequential order
Dim loadsofNumbers (999) As integer

- populated
search for = 22

- sorted
0 - 1000

- binary search
500

if what you are searching for is less than then it dstroys.






















Chapter 8 revise and finalise.

Chapter 8 completed,


In class we worked on functions.



Public function MultiplyAge(intAge As Integer) As Integer


intAge = intAge *3

Return intAge Multiply age(*)
End Function

" This can also be used as a procedure by changing the public function to a Public sub."

Public Sub MultiplyAge(intAge As Integer) As Integer

lbl = intAge lbl.text = Multiply age(*)

End Sub

Try-catch

User not entering numbers,
Also fixes errors.

A bad thing can happen or a few bad things can happen and so a try-catch statement is used to make sure that what is entered is a number and not text.

Over flow exception = a value exceeds its assigned data type.
Format exception = a varaible is converted to another type that is not possible.