At part 1 we specify what the program will do and we create the SQL statement that will create the database, now we will start building our GUI.
In the database we specify 5 fields
Now we need to create on our first form 4 text boxes we do not need to create 5 because the id will be auto increment by the SQL engine. The reason is to have unique keys for each record that we will have in our database but I imagine that you already know this.
Now create the text boxes on the form and give them a sensible name.
The names that I gave are: txtName, txtSurname, txtAddress and txtTelephone.
Your GUI should look like this:
Sorry GUI removed
As you can see in the picture the user can input all the necessary information that is needed for the program to store a client.
As we said above the id field does not exist in the form because it will be auto increment, the SQL engine will automatically increase the number this will insure unique number (primary key). So later we can perform transactions with our records like update record, delete record.
Now click on the insert button that you created and make the program to check if the 4 fields are empty.
The program also checks if the telephone is number
The code is:
Also we will make the program to check if the database exist and create it using the first statement that we made in the fist tutorial.
In the database we specify 5 fields
Now we need to create on our first form 4 text boxes we do not need to create 5 because the id will be auto increment by the SQL engine. The reason is to have unique keys for each record that we will have in our database but I imagine that you already know this.
Now create the text boxes on the form and give them a sensible name.
The names that I gave are: txtName, txtSurname, txtAddress and txtTelephone.
Your GUI should look like this:
Sorry GUI removed
As you can see in the picture the user can input all the necessary information that is needed for the program to store a client.
As we said above the id field does not exist in the form because it will be auto increment, the SQL engine will automatically increase the number this will insure unique number (primary key). So later we can perform transactions with our records like update record, delete record.
Now click on the insert button that you created and make the program to check if the 4 fields are empty.
The program also checks if the telephone is number
The code is:
Dim name, surname, address As StringIn the next tutorial we will create the SQL statement that will insert the record in the database.
Dim telephone As Integer
name = txtName.Text
surname = txtsurname.Text
address = txtaddress.Text
If name = "" Then
MessageBox.Show("Please type the name!")
Exit Sub
End If
If surname = "" Then
MessageBox.Show("Please type the surname!")
Exit Sub
End If
If address = "" Then
MessageBox.Show("Please type the address!")
Exit Sub
End If
If IsNumeric(txttelephone.Text) = True Then
telephone = txttelephone.Text
Else
MessageBox.Show("Telephone number error")
Exit Sub
End If
Also we will make the program to check if the database exist and create it using the first statement that we made in the fist tutorial.
No comments:
Post a Comment