30 August, 2009

Session 13 Activity

Just finished the Database design and programming activity and am worried that I have done something wrong as it seemed pretty straight forward and only took half an hour to complete. And even then I created the form from scratch rather than saving a copy of the one we did in class, even if I did then pretty much replicate it. What have I missed??

25 August, 2009

Session 12

* Today we added some select clauses that contained filters (WHERE, LIKE) to our array, e.g.
"SELECT * FROM ApprovedTravelRequests WHERE Location = 'Richmond, VA'"
* The above query would return all records from the table where the Location was Richmond, VA.
* We can also run a "fuzzy" query that only looks for certain letters within the words:
1. "SELECT * FROM ApprovedTravelRequests WHERE Location LIKE 'R%'"
2. "SELECT * FROM ApprovedTravelRequests WHERE Location LIKE '%R'"
3. "SELECT * FROM ApprovedTravelRequests WHERE Location LIKE '%R%'"
* Example 1 would return all records where the location STARTS with an R, example 2 would return all records where the location ENDS with an R, example 3 would return all records where the location CONTAINS an R ANYWHERE in the name.
* The Percentage sign % is called a WILD CARD CHARACTER.
* We can also run queries using the relational operators >, <, >=, <=, <>, =, for example:
"SELECT * FROM ApprovedTravelRequests WHERE [Travel Cost] >= 1000"
* When using a numeric value there is no need to put it inside ''.
* We can also run queries using the logical operators AND, OR, for example:
"SELECT * FROM ApprovedTravelRequests WHERE [First Name] = 'Janet' And [Last Name] = 'Dunford'"
"SELECT * FROM ApprovedTravelRequests WHERE [First Name] = 'Janet' Or [Last Name] = 'Tirrell'"

Session 11

* In this session we talked a little more about SQL - Structured Query Language.
* An SQL statement always starts with either SELECT, DELETE, UPDATE or INSERT.
* We can also add a FILTER to an SQL statement, for example:
"SELECT * FROM ApprovedTravelRequests WHERE FirstName = 'Janet'"
SELECT * = SELECT ALL
ApprovedTravelRequests = Name of Table
WHERE = Filter
FirstName = Field
* The above will return all the details for that person.
* We can also specify which details should be returned:
"SELECT Location FROM ApprovedTravelRequests WHERE FirstName = 'Janet'"
* The above will only return the details from the Location field.
* To return the details from more than one field we use a comma between the field names:
"SELECT Location, TripDates FROM ApprovedTravelRequests WHERE FirstName = 'Janet'"

21 August, 2009

Session 10

* There are four database operations, three of which cause changes: 1. insert; 2. delete; 3. update; 4. select (only opens it).
* When constructing a database, ID IS KING!!
* All databases must 1. have an ID column, 2. use the AutoNumber data type to populate this column, 3. have a primary key defined.
* The new version of Access does these three things for you!
* DO NOT have spaces in your field names - either use capitals or underscores.
* SQL stands for Structured Query Language.
* In SQL * means all, e.g. the command "Select * from TableName".
* When writing our code in Visual Basic, objects need to be connected to a database.
* Rachael used the following analogies:
1. Connection String - The Supermarket address.
2. Connection Object - The car.
3. Command Object - The shopping list.
4. DataAdapter Object - Mum doing the shopping.
5. DataSet Object - The pantry.

17 August, 2009

Session 9

* Today we started talking about databases.
* A database is a type of PERSISTANT data storage.
* There are 2 different types of database - 1. Flat file and 2. Relational.
* An example of a flat file database would be an Excel spreadsheet (it deals with only one topic).
* An example of a relational database would be an Access file (can contain many different areas of information).
* The common features of relational databases are: creating tables; populating tables; retrieving data; generating queries; generating reports.
* Each TABLE in a database deals with a specific topic of information.
* Every column in a table is called a FIELD.
* Every row in a table is called a RECORD.
* When you define a new field you must also define the data type, e.g. text, memo, number, date/time, yes/no, currency, etc.
* Using related tables reduces repetition of data.
* When you are working with databases understanding how the IDs work is crucial.
* The first thing you should do when you build a table is define an ID field.
* The AUTONUMBER data type in Access provides an automatically incremented, sequential and unique number for our IDs.
* Every table has one PRIMARY KEY - a unique identifying feature (field) for the table.

Databases

* A database is a method of storing, managing and retrieving related information using tables.
* Technically a database is anything that stores information, so telephone books, filing cabinets, dictionaries, etc. are all databases.
* In business, common databases are customer lists, product information, mailing lists, etc.

http://www.asp.net/learn/sql-videos/video-103.aspx is a link to a video tutorial about databases that all who have commented on it say is a good, easy to understand tutorial for beginners.

11 August, 2009

Session 8

* In todays class we talked about file handling (working with simple text files).
* We talked about performing tasks such as creating, writing, reading, deleting, moving and copying the text files.
* We had to import the class library for StreamReader and StreamWriter to the application as it was not automatically included: Imports System.IO
* We then added code to the click event of each button on our form to perform the desired task, e.g.
1. btnCreateFile - File.Create("C:\mycreatefile.txt")
2. btnWriteFile - Dim objWriter As New StreamWriter("C:\mywritefile.txt")
objWriter.WriteLine("I am NOT a multimedia rockstar!")
objWriter.Close()
3. btnReadLine - Dim objReader As StreamReader
objReader = File.OpenText("C:\mywritefile.txt")
txtFileContents.Text = objReader.ReadLine()
objReader.Close()
4. btnReadFile - as btnReadLine except .ReadToEnd() replaces .ReadLine()
5. btnMoveFile - File.Move ("C:\mycreatefile.txt", "E:\Chisholm\Rachael\mycreatefile.txt")
6. btnCopyFile - File.Copy("C:\mywritefile.txt", "E:\Chisholm\Rachael\mywritefile.txt")
7. btnDeleteFile - File.Delete("E:\Chisholm\Rachael\mywritefile.txt")

10 August, 2009

Chapter 9 project

On page 695, where they give you the details for designing the form, there is a slight typo in the text for the button - it reads Calculate Depression instead of Calculate Depreciation! It's only a small typo and nothing to worry about, but seeing as my head is already buzzing trying to make sense of this chapter, it at least afforded me a little chuckle!! My Calculated Depression - off the scale :o).

Session 7

* In todays class, after the Chapter 8 test, we talked in more detail about arrays.
* An array is a variable that can store more than one value.
* Each item in an array that contains a value is called an element.
* Arrays provide access to data by using a numeric index to identify each element.
* To initialize an array you must write a declaration statement that includes the name of the array, how many items it has to store, and what sort of data it can store.
* Setting the size of an array is called dimensioning the array.
* If you know the values to be placed in each element you can declare the the array by assigning values to the elements.
* Parallel arrays store data in two or more arrays.
* If a number is not used int he declaration statement the array us implicitly sized, i.e. the number of values is determined at execution.
* The other aspects of arrays covered in Chapter 9 are:
1. Initializing an array with default values.
2. Accessing array elements using a loop.
3. Array boundaries.
4. Reinitialising an array.
5. Using the length property.
6. Scope of arrays.
7. Passing an array.
8. Sorting an array.
9. Searching an array.
10. Two dimensional arrays.

09 August, 2009

Chapter 8 project

In the btnClear_Click event handler, nine lines of code are used to change various labels, buttons, text boxes and list boxes from visisble to not visible. Isn't there a way of doing this in one line of code, i.e. so that you can say Me.(this and this and this and this).Visible = False??

Session 6

* Today we talked about the Try-Catch set of statements as well as the various types of exceptions used when handling errors.
* An exception is a class of objects.
* All exceptions share certain characteristics.
* Some of the possible exception types include:
1. ArgumentNullException - a variable that has no value is passed to a procedure;
2. DivideByZeroException - a value is divided by zero;
3. FormatException - a variable is converted to another type that is not possible;
4. NullReferenceException - a procedure is called when the result is not possible;
5. OverflowException - a value exceeds its assigned data type;
6. SystemException - used to catch all generic exceptions.

03 August, 2009

Session 5

* After the test we started working through Chapter 8, Using Procedures and Exception Handling.
* We talked about the fact that it's good to break your code into multiple small procedures so that they are easy to maintain and re-use.
* We recapped the difference between procedures and functions (a function returns a value).
* An example of procedure might be (the keyword sub tells us it is a procedure):
Public Sub MyProcedure()
'Do Something
End Sub
* An example of a function might be:
Public Function MyFunction() As Boolean
'Do Something
End Function
* Function is the keyword, MyFunction is the name, Boolean is the value.
* The data type or value stipulated depends on what the code is looking for.
* An example of a function is the IsNumeric function - it is a common task for which code has been written and added to the VB library so that it can be reused.
* We also briefly touched on the parameters ByVal and ByRef.
* When you enter arguments into a function, intellisense automatically adds in one of these parameters for each of the arguments.
* ByVal passes the actual object to the function (a duplicate is created), ByRef passes a reference to the object to the function.

02 August, 2009

Chapter 7 Test.

Just finished studying for the Chapter 7 test. Don't know if it's just me, but the multiple choice questions seemed a bit more "duh'uh" than normal, e.g. Which property of a CheckBox indicates that it has been checked? Erm, the Checked property??!! And which object shows the days organised by month relevant to the year? Erm, Calendar anyone??!! Or am I just being a smart arse ...

Chapter 7 project

This was a horrible project as the Guided Program Development had lots of confusing and omitted information. Once I got past the part where you had to resize and position the div elements it got a bit better. Spent a lot of time looking back in the chapter for information that seemed to be missed out though, for example the Guided Program Development omitted to tell you what to name the Calendar object so I had errors in my code. Luckily it was pretty easy to correct.

Session 4

* Last Tuesday we started off by talkign about string functions:
.Length - finds the length of strings
.ToLower() - converts the string to all lower case
.ToUpper() - converts the string to all upper case

* We also talked about Validation Controls, e.g. The RequiredFieldValidator.
* The RFV can be assigned a TextBox to "watch" or we can code the validation ourselves.

* Finally we worked on the Chapter 7 project ...

I Tweeted!

In session 3 we also set up Twitter accounts! My user name is Chippyandme.

We then opened up the Twitterizer.Framework file and imported the framework so that we could update our Twitter posts direct from our VB program - very cool!!

Session 3

Last Monday we started working through Chapter 7: Creating Web Applications.
* When you open a new website the basic metadata and html are already in place.
* The .aspx file extension refers to active server pages.
* The top line of the code tells the web page where all the dynamic code is.
* There are 3 possible views: Design (preview page), Split and Source (code only).
* In Solution Explorer the .aspx.vb file is where our VB code will go.
* When you run a Web Application for the first time an error message pops up - leave it as default and click on OK.
* When you run the program it mocks up the webpage in IE, and when you look at the source code extra code has been added in. This comes from the web.config file which never leaves the server.
* It is an excellent place to store sensitive information.
* It is written in XML which is a hierarchy of nodes not code and is written in plain English which makes it the transmission format of choice.

Session 2

At the start of session 2 we talked a little bit about Do loops.
* There are 2 types of Do loops - Do Until and Do While.
* Each of these can be either Top Controlled or Bottom Controlled, e.g.
TOP Controlled:
Do Until 1 To 10
'Body
Next
BOTTOM Controlled:
Do
'Body
Loop Until x = 10
* After this we worked through the Chapter 6 project - the Highway Radar Checkpoint program.

Semester 2 Begins.

Little bit slow at getting some posts up this semester - sorry.

Session 1 was spent mostly doing some revision of what we learned last semester, such as:
* Declaring and assigning variables
* Variable types e.g. string, char, integer, decimal, date, boolean
* Scope and lifetime of variables
* The concatenation operator &
* Using the MessageBox show method
* The difference between procedures and functions
* Decision structures - If statements and Selected Case statements
* The SDLC (Software Development Life Cycle)
* Class Diagrams
* Arrays
* Loops: For ... Next loops (when you DO know the number of loops to be executed) and Do loops (when you DO NOT know the number of loops to be executed)