Guts and Core of the program

July 18, 2008 at 7:10 am (Achievement, Criminal Search, Limits, Obstacles) (, , , , , , , , )

The criminal search form is the hardest, but most rewarding form i have ever created; it allows users to search the criminal database in superior flexibility, users have the ability to:

- Quick search the database; returning all criminal records and displaying them in the data grid

- Advanced Search the database; users have the ability to specify any component of the database, and querry the database against a set piece of data

-users have the ability to double click search results and view more details of the selected record on a seperate form, and have the ability to print the record from there.

It took some time to understand hwo to develop this advanced search sql coding:

from learning the basics of OLEDB, i had the ability to grab and display data, and vise versa back to the database, but no tutorial that i  had come across outlined how to manipulate the sql  to achieve the advanced search… after carefully looking at the code i have already established.. i realised i needed to create variables within variables to achieve this…. the concept evolved around this line of code

—————  code  ——————-

da = New OleDb.Ole.DbDataAdapter(sql, connection)

—————————————-

where sql was a variable. so i thought to my self, how can this variable which represents a string change and alter to fit the user’s specified advanced search data set.. the answer was within the definition of what a variable is, itself. vairbales represent something else.. so why not have a variable that represents and sql command, that also contains variables to define the sql’s string command! — a bit hard to explain in words, but its my home grown method that works.

within any SQL command you need:

-SELECT   -FROM -WHERE

first step to achieve my advanced sql search was to have variables define what each of these sql Components will contain:

SELECT (the fields) — depending on whether the user selects to hide or show some fields we need variables to represent this :

———- code snippit —————

IF txtnationality.Text = “Any” Then

sqlselect = sqlselect +“, CNationality”
ElseIf txtnationality.Text = “Hide” Then
sqlselect = sqlselect   

 Else
sqlselect = sqlselect + “, CNationality”
End If
—————code snippit —————-
once i defined a variable which checks each part of the advanced search ofr what it contains, i move on to the FROM, which is still as usual as we only use one table, in my case the criminal database
——— code ———–
FROM criminal_database
————————-
The tricky part is the WHERE:
—————————— code snippit ————————————

If txtlastname.Text = “” And txtfname.Text = “” Then

 

whereselect = whereselect 

ElseIf txtlastname.Text = “” And txtfname.Text <> “” Then

 

whereselect = whereselect 

ElseIf txtlastname.Text <> “” And txtfname.Text = “” Then

 

whereselect =

“” & “CSurname = ‘” & Sname & “‘” 

ElseIf txtlastname.Text <> “” And txtfname.Text <> “” Then

 

whereselect = whereselect +

” AND “ + “” & “CSurname = ‘” & Sname & “‘” 

End If

——————————————————————————-

Though overall it may seem not to hard, and it might not involve a tonne of coding, the concept and technique is dificult to grasp, as to begin with to find the actual proper code to add a vairbale into sql is hard,and to implement it the proper way also takes time to realise.. not only that but you must think of every possible option the user may select, and test whether your system may crash, or provide an unexpected result… it is not as easy at it seems… plus, some consequences after the whole sql search, such as the data grid will not sort as expected.. because you find out that there are limits to sql suh as:

sql can not jump from refering to a variable that is integer defined to a variable that is string defined and put it all into one big variable that can only be defined in once instance, i.e: only a string, not integer and string at the same time!… so solve that problem i made all my integers into string, cause you cant go string to integer .. (daa) .. but then there are more consequences to that.. now when ever  i try to sort my list after (like sorting in terms of age) the sort wont work properly… because its sorting strings.. different to sorting integers… so to solve that problem you must have the same number of characters within that field for every cell.. hence if your trying to sort this string :”5, 792, 181″ … it wont return 5, 181, 792″ but rather “5,792, 181″ ???? valid, but unexpected…. to solve that problem every component of that must have the maximum amount of characters in the set i.e: “005,792,181″ … then it will work!…

DBNull errors are also common, especially when i am trying to grab records after a user double clicks a certain row, especially if they click the blank row at the end… took some searching to find that answer DBNull.value which i covered in my previous posts.

Overall this part of the assignment was the hardest in terms of its concept, technique, and tediousness in every single part of the sql coding, and after effects…..  

Permalink Leave a Comment

DBNULL type to STRING ERROR!!!!

July 18, 2008 at 6:22 am (Achievement, Limits, Obstacles) (, , , , )

As i fill my datagridview, i select an empty row and try to print… then i get some crazy error message, and program crashes…. all because of an empty cell issue, where vb cant recognise it!!

But after soem research, found that to compare if a record or cell is empty, a special code made just for this “DBNull.value” is what  i need to check!!! omg, saved my life from disaster errors!

Permalink Leave a Comment

Changing Objectives – WIS and WPS

July 18, 2008 at 5:59 am (Limits, Obstacles) (, , )

in my objectives, i also outline that users will have the ability to add, edit, sort, and delete records in regarding to the weapons intelligence system, and witness protection system.

unfortunatly time once again is ahead of me, and due to this  i will not be able to complete these objectives and hand in this assignment on time.. hence  i am altering these objectives to only include the ability for users to view and print specific records.

Permalink Leave a Comment

Printing Concept

July 18, 2008 at 5:51 am (Obstacles) ()

throughout my objectives, i continually mention that users will have the ability to print records and forms, yet i have only had expirience in printing with vb6, not vb.net 2005… the printing component in vb.net is different, something  i am not familliar with yet, hence printing will be harder than i thought…

i am going through this tutorial so i can get a background and understanding to printing in vb.net

http://visualbasic.about.com/od/usingvbnet/a/printvb2005.htm

Permalink Leave a Comment

Choice of Music?

July 18, 2008 at 5:38 am (Achievement, Obstacles) ()

Permalink Leave a Comment

New User – The functions

July 18, 2008 at 4:55 am (New User, Obstacles) (, , , , , )

decided to create a new user form, this is where people who are new to this program and dont have a combination code can create a new account ans store thier details to thier local database.

This page should include the typic fill in form components including:

- first name  – Surname – Date of Birth – FBI department - combination code

the first name, surname, DOB, and department are all user inputted, but the combination code will be a generated random 5 digit number. Difficulty with this is the fact this we are dealing with numbers:

in vb, if you make a random generator code for numbers between 0 and  99999 (5 digits), if the result is 321 obviously it does not have 5 digits, because the 0’s dissapear because they are irrelivant and take up space.. this is a problem, as i Want 5 digits…

Permalink Leave a Comment

URL of a Web Browser

July 18, 2008 at 3:47 am (Limits, Obstacles) (, )

With the great advantages of a web browser, the only obstacle i face with using this short cut my lack of knowledge in coding with a web browser. I am not able to to change the url of a web browser:

everytime i try to tell the code:

dim urlz as string = “C:\FBIIC\playmusic.swf”
webbrowser1.url.string = urlz

i continue to get the error “can not convert url type to string”

this seems to be challenging as i have tries multiple ways but continue to get the same error… so far i have not been able to find the solution…

Permalink Leave a Comment

Music Concept

July 18, 2008 at 3:37 am (Achievement, Concepts, Obstacles) (, , )

Well, after sharing my little secret on how to add music and video with ease, i decided to add some background music into my program. to do this i need a form that will always be “hiden” i.e: always at the back of any other form. after this i can use my web browser to play music from a specific file that will naturally loop throughout the whole program.

This the implementation of background music i thought that it would be appropriate to include a mute and unmute button in my side bar menu; meaning an extra  2 functionality buttons!

in order to achieve a mute and unmute button, instead of actually doing what it says to do, because my music is within a web browser, if i change the url of the web browser, then the music would “stop” and if i re assign the url back to the music’s file path, it would seem to continue playing the music.. a much easier solution compared to actually using the difficult coding of changing the computers master volume!

another genuis short cut when using a web browser!

———— code————-

Private Sub mutevolume_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles

mutevolume.Click

Dim navmute As String = “”

musicbackgroundweb.musicmaker.Navigate(navmute)

End Sub

Private Sub about_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles

about.ClickAboutfbiic.Show()

 End Sub

Permalink Leave a Comment