Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

"You see, there's different kinds of dead: there's sort of dead, mostly dead, and all dead. This fella here, he's only sort of dead" - Miracle Max (The Princess Bride).

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

No problem. If you haven't selected any options in the filter you want to select all records in which case you don't want to add a WHERE clause. For every checkbox that was selected you add another piece to the WHERE clause string. If no checkboxes were selected then the WHERE string will be empty. So in English the first line is

If any filter options (checkboxes) were selected then
    add a WHERE clause to the query

If you have more then one checkbox selected you have to use AND or OR to include the option in the WHERE clause. For example, if you only had one option the clause would look like

WHERE Gender = 'Male'

but if two are selected then you need

WHERE Gender = 'Male' AND Status = 'Regular'

but it gets a little ugly determining whether or not you have one option or more than one selected so it is easier to just add the conjunction to the end of each option and just remove the last one at the end so we get

WHERE Gender = 'Male' AND Status = 'Regular' AND

and then trim it to

WHERE Gender = 'Male' AND Status = 'Regular'

Note that the base query is

"SELECT * FROM Employees    "

which has at least three extra blanks on the end. That's so that when we trim the last three characters we just lop off blanks instead …

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Dani has said several times before in this forum that there is nothing wrong with resurrecting old threads as long as the new posts are relevant to the topic.

That's why I included the phrase UNLESS YOU HAVE SOMETHING REALLY VALUABLE TO ADD. When you see three year old threads like this one that are clearly marked as solved then they really do not need further posts.

Apparently people are ignoring the banner. I thought that by putting text in the actual text entry area it would force people to read it. Even a pop-up on old solved threads would be useful. I, personally, have added to recently solved posts with tidbits that might be worth considering even if the actual question has been addressed so I can see that there are cases where additional posts are a good idea. But posting in a three year old solved thread is probably not.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

@TnTinMN - RE:If mbox.Checked And fbox.Checked Then

If you look at the project you will see he has logic to ensure that male and female cannot both be checked at the same time.

My toes are just fine ;-)

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

This has surely been mentioned before. I've noticed an increase in the number of noobs who are resurrecting old threads. Based on what I did shortly after joining (before getting lightly slapped on the wrist), it's likely the posters just didn't notice the thread date. Apparently the purple banner isn't sufficient. How about a pop-up when the Reply textbox gets focus or when a character is typed with the same warning and the option to continue if something really earth shatteringly worthwhile is to be added to the conversation? I know we all hate pop-ups.

As an alternate suggestion, you know when you receive a PM, the reply box already has some greyed out text from the original message? How about preloading the reply box on old threads with something like

WE APPRECIATE YOUR DESIRE TO CONTRIBUTE BUT THIS POST IS MORE THAN 3 MONTHS OLD. PLEASE DO NOT REPLY UNLESS YOU HAVE SOMETHING REALLY VALUABLE TO ADD. POSTING IN OLD THREADS WITHOUT GOOD REASON MAY RESULT IN INFRACTIONS.

This text could be automatically deleted when the box gets focus or when the first keystroke is detected.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Please check the dates on threads before posting. This thread is more than two years old. Resurrecting old threads may result in infractions.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

For the sake of completeness, Microsoft SQL is also free unless you are planning databases in excess of (I think the limit is) 4 gig. And you can also download the SQL Server Management Console for free which makes setting up and administering the databases much easier.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You hard coded the connection string a dozen or more times. The actual connection string should appear only once. If you ever have to change it you don't want to have to change it in multiple places. If you do you are likely to miss one.

You don't name your controls. They should never be named Button1, Button2, etc except for trivial examples. When working with a large block of code, using a name like btnRefresh makes the code much easier to follow.

You haven't added any comments to your code. This, in and of itself, is cause for justifiable flogging. Here I am speaking as a 30+ year veteran as a maintenance programmer where I had to work with untold thousands of lines of other people's code. If you are doing this as an assignment, some markers can be brutal in taking of marks for uncommented code. I know. I was one of them. And I learned that less the hard way when I lost marks on early assignments.

I made the following additions at the top of Main

Public Class Main

    Const DATABASE = "D:\Downloads\EmployeeRecords\EmployeeRecords\bin\Debug\Employeedb.mdb"
    Public ConStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DATABASE & ";"
    Public conn As New OleDbConnection(ConStr)

You can now use the same connection object (conn) everywhere in your project. However, in the login form you must now use Main.conn instead of just conn. The following is the replaacement code for Button5.Click. You can take out the MsgBox once you see it …

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Oh. OK.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I can't help you because you won't provide any details inspite of several attempts to get you to do so. Perhaps someone else will have better luck.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Any chance you could also post a sample database?

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Basically the NRA is upholding the rights of the gun manufacturers to make a profit and damn public safety. To use a timeworn example, the right to free speech is not absolute (the whole shouting "fire" in a crowded theatre thing) so why should second amendment rights be any different?

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Perhaps a tad blunt. What I am trying to get across is that if only one person will be updating the database then you don't have to worry about record or table locking to prevent an attempt for two people to update at the same time.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

The first thing you should do is use parameterized queries. A simple example of how to do that can be found here. As for doing a select, a basic select would look like

SELECT * FROM ChkInOut WHERE ControlNo = '12012996'

I'm assuming because you put single quotes around 12012996 that it is stored as a string rather than an int. As a parameterised query that would look like

cmd.CommandText = "SELECT * FROM ChkInOut WHERE ControlNo = @ctrlNo"
cmd.Parameters.AddWithValue("@ctrlNo",txtCtrlno.Text)

where txtCtrlNo is a text control containing the value to search for.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I could have a look, but as I said, I don't know a lot about the new layers such as DataTables, DataAdapters, etc. I'll offer any advice I can.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I don't know from DataTables and DataAdapters. As Scotty says, "the fancier they make the plumbing the easier it is to plug up the drains." I use mostly ADO when I want to do any database work, but what I suggested is an easy way to build the query. What in particular are you having trouble with in my code? I'll try to explain further.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Over the past two decades, the NRA has not only been able to stop gun control laws, but even debate on the subject. The Centers for Disease Control funds research into the causes of death in the United States, including firearms — or at least it used to. In 1996, after various studies funded by the agency found that guns can be dangerous, the gun lobby mobilized to punish the agency. First, Republicans tried to eliminate entirely the National Center for Injury Prevention and Control, the bureau responsible for the research. When that failed, Rep. Jay Dickey, a Republican from Arkansas, successfully pushed through an amendment that stripped $2.6 million from the CDC’s budget (the amount it had spent on gun research in the previous year) and outlawed research on gun control with a provision that reads: “None of the funds made available for injury prevention and control at the Centers for Disease Control and Prevention may be used to advocate or promote gun control.”

See the full article here

So the NRA is not only opposed to any type of regulation no matter how bat-crap crazy everything gets, they are also opposed to anyone actually studying the situation to see how bad it is.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I did a minor edit after you responded but before I posted and saw your reply. The process is really not that compliciated. All I am doing is building up the query a bit at a time. In people speak it's like:

  • I want all employees
  • oh yeah, I just want regular employees
  • oh yeah, I also want contractual employees

Every time you find a checkbox you add a bit to the end of the query. Then when you are done you lop off the last two chars to prevent a dangling "OR". You can get sneaky when you want to avoid a lot of repetitive typing or complex If statements.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Compose the query first then do the DB access later as in

Dim con As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & System.Environment.CurrentDirectory & "\employeedb.mdb;")
Dim cmd As New OleDbCommand("", con)

Dim query As String = "SELECT * FROM Employees   "
Dim where As String = ""

If cbox.Checked Then where &= " status = 'Regular'     OR"
If rbox.Checked Then where &= " status = 'Contractual' OR"
If mbox.Checked Then where &= " gender = 'Male'        OR"
If fbox.Checked Then where &= " gender = 'Female'        "

If where <> "" Then query &= "WHERE" & where

cmd.CommandText = query.Substring(0, Len(query) - 2)

etc.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

By the way, the NRA has steadfastly opposed every provision in the Brady Bill. They have blocked legislation that would allow inter-agency sharing of firearms data and they have blocked introduction of technology that would allow better tracking and identification of guns and that would allow only the legal owner of the gun to fire said weapon. The NRA is not about public safety or reasonable regulation. The NRA is in favour of more profits for gun manufacturers.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

If your statement were correct then why didn't the Brady gun control laws stop gun violence?

The Brady Act requires that background checks be conducted on individuals before a firearm may be purchased from a federally licensed dealer, manufacturer or importer—unless an exception applies.

Passing a law in and of itself will not stop gun violence. The law has to have enforcement and it can't have loopholes. Background checks are not required for

  • sales at gun shows
  • sales by private individuals

I recall reading that approximately 40% of all firearms fall through this enormous loophole.

Also, change takes time. You can't expect to see immediate results no matter what steps are taken. When Obama was elected the first time did you expect he would fix the mess that Bush took 8 years to correct overnight? If the Dems get their gun reforms passed (whatever form they take), and another shooting occurs in 3-4 months, are you going to sit back and say "see, I told you it wouldn't work"?

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

It's warmed up to a balmy -19C (was -30).

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Another lie regarding Newtown - The killings happened because we took God out of the schools.

Right. How many child molestations has God prevented in churches? But then again, lesbians caused Katrina so I suppose it is conceivable that atheists caused Newtown.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

even if you take away the guns, people still kill each other

And how many people would have died in Aurora had the killer been armed with a knife instead of semi-automatic weapons?

When mandatory seatbely legislation was introduced up here there were a lot of protests. Someone always trotted out the argument that even people wearing seatbelts can die. Usually they cited a case where the person died because he/she was wearing a seatbelt such as a side impact or drowning. They never considered actually thinking that these are one-in-ten-thousand examples. Take all of the mass shootings and imagine the killer was armed only with a knife. How much lower would the death toll have been? How about the highway sniper in Washington a while back? Kind of hard to do that sort of mayhem with a knife.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Is that along the lines of: it gives you that warming you get after wetting youself that ultimately turns into a wet smelly mess?

Maybe not quite where I was heading but sure. Either way you are losing precious body heat.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

It works in other countries because their governments have already disarmed its citizens.

I disagree. Our government here in Canada has not disarmed the citizens and yet we don't seem to have any where near your level of gun violence. As for the NRA, until 1977 it was a major supporter of most of the measures that the NRA opposes today. That was the year they got taken over by the nut jobs and went totally bat-crap insane. That explains why the majority (84% the last time I heard) support gun regulation while the executives oppose it.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

That is about as useful as saying "I want to write a program that does stuff. Any suggestions?". I don't mean to be rude but how you design will depend on how the database will be accessed, as I stated earlier, and you didn't provide any further information.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Question: How many NRA spokepersons does it take to screw in a light bulb?
Answer: More guns.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

World Famous Lie: Banning assult weapons will make America safer place to live.

Seems to work in every other civilized country in the world. And the argument "if we ban guns then only criminals will have guns" is invalid. If it held water then there would be no point in having any laws.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Yes, maybe my comment was going too far.

Just maybe? I'll chalk it up to one of those senior moments where you make a comment without quite considering the full implication. I've had a few myself.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

It's a board game, I think by Milton Bradley. The rules of Life are probably online somewhere.

Or if you meant the other thing then it's likely a subjective thing. I'm still a work in progress. I'll get back to you when I'm done.

I plan to live forever. So far so good. - author unknown

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

A gun in the home makes the likelihood of

  • homicide three times higher
  • suicide three to five times higher
  • accidental death four times higher

An abused woman is six times more likely to be killed if there is a gun in the home.

For every time a gun in the home injures or kills in self-defense, there are 11 completed and attempted gun suicides, seven criminal assaults and homicides with a gun, and four unintentional shooting deaths or injuries.

One third of all households with children younger than eighteen have a gun and more than 40 percent of gun-owning households with children store their guns unlocked.

More than half of youth who committed suicide with a gun obtained the gun from their home.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Maybe that's a good thing. Remove the stupid gens from humanity.

Right. Because the teenage (and younger) boys and girls who kill themselves after (in some cases) years of non-stop bullying are nothing but collections of junk genes while those who preyed upon them with no empathy are the crowning glory of human evolution.

I find your comment completely heartless and contemptible.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Was that from the Kama Sutra, or from the Bible?

There is a form of the golden rule in just about every religion ever invented.

"Never impose on others what you would not choose for yourself." – Confucianism

"If people regarded other people's families in the same way that they regard their own, who then would incite their own family to attack that of another? "For one would do for others as one would do for oneself." – Mozi

"Now this is the command: Do to the doer to cause that he do thus to you." - Egyptian

"Do not to your neighbor what you would take ill from him." – Pittacus

"What thou avoidest suffering thyself seek not to impose on others." – Epictetus

"Expect from others what you did to them" - Seneca

"Hurt not others in ways that you yourself would find hurtful." - Buddhism

"And if thine eyes be turned towards justice, choose thou for thy neighbour that which thou choosest for thyself." - Bahai

"One should never do that to another which one regards as injurious to one’s own self." - Hinduism

"None of you truly believes until he wishes for his brother what he wishes for himself." - Islam

"He who desires his own good, should avoid causing any harm to a living being." - Jainism

"Oh, do as you would be done by." - Quakerism

"Regard your neighbor's gain as your own gain, and your neighbor's loss as your own loss." …

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Please review the member rules. One of them states

  • Do not hijack old forum threads by posting a new question as a reply to an old one.
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Any other barbershoppers (present or former) out there?

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

It's like if you take all your money out of the bank and start spending it. You might feel rich but in fact you are rapidly getting poorer.

OK. So I suck at analogies.

<M/> commented: No, it was pretty good +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Inside the loop you can save some typing by

ListView1.Items.Add(New ListViewItem({ _
    numberrow.ItemArray.GetValue(0).ToString.ToUpper, _
    numberrow.ItemArray.GetValue(1).ToString.ToUpper, _
    numberrow.ItemArray.GetValue(2).ToString.ToUpper, _
    numberrow.ItemArray.GetValue(3).ToString.ToUpper, _
    numberrow.ItemArray.GetValue(4).ToString.ToUpper})
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

A database can be accessed by more than one person (or process) at a time. How you set up your access will depend on whether more than one person at a time will be modifying the same areas. I can't offer any suggestions without knowing how the database will be used.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

What have you done so far? We are not going to design it for you but if you have specific questions perhaps we can answer them.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

But drinking alcohol on the other hand (although unhealthy) certainly keeps you warm, that's not a myth.

Alcohol dilates the blood vessels. It may make you feel warmer but the net effect is actually to make your body lose heat faster.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I prefer the change of seasons. Makes you appreciate both. Here in Manitoba in the winter, except when it gets below -18C we like to cross country ski. During mosquito season (June through September) we go to the cottage at the lake (got about 450 feet of really nice private lake-front). Actually, the mosquitoes stay in Manitoba. The cottage is in Ontario. Spring and fall are gorgeous.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You are in California? Where it is warm? You suck!

Actually, given a choice of extremes (hot or cold) I prefer the cold. I spent two weeks in Phoenix (actually Tempe, but that's splitting hairs) in August several years back. It was +47C or hotter the entire time I was there. That's 116F for you Yanks. It was like taking a brick to the face every time I stepped outside. And things in the car kept melting. You can always throw on another sweater or light a fire in the cold. Can't do much about the heat except bitch and sweat.

<M/> commented: Agreeable +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I am also a newbie

No problem. I did the same thing when I was a noob. That's why you got the boilerplate. Unfortunately it is a fact that a lot of people who ask questions never bother to mark their threads as solved.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

-24C with a wind chill of -31C. It's warmer now than it's been for the last few days.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Thank u for your very interesting and a remarkable reply Reverend Jim. That helps much.

Being lazy is not a great way to get through life. Being lazy with attitude is even worse. You got a response with links to five different threads where your issue was addressed. The acceptable response would have been

  1. check out the suggested threads
  2. reply to this thread with a "thanks for the suggestions"

I, for one, am getting tired of people whose first reaction when they don't know something is to ask someone else to do the legwork for them. Simply going to google and entering the string "working with time in vb.net" gets a number of useful responses. But reading them and working through a few examples would involve effort on your part and I get the impression that "effort" is not "your thang".

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You can also add an entire row to a listview (in details view) in one step by

ListView1.Items.Add(New ListViewItem({"col1data","col2data","col3data"}))

In your case the parameter(s) would be

{reader.GetString(0),reader.GetString(1),reader.GetString(2)}
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

For details on how to use parameterized queries please refer to this code snippet. It also suggests how to adjust your code formatting to make queries easier to read.

Begginnerdev commented: Nice link +7
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

We appreciate your willingness to contribute but please check the dates on posts before you respond to them This thread is more than three years old and it is likely that the original poster (OP) no longer needs help with this issue. Reviving this thread pushes more recent threads further down the list. If you continue to revive old threads you may be hit with an infraction.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Again no; The website, code, etc is all written by Daniweb's coding team. But the site itself, its content, its activity, etc is made by the members. Without them, it would die.

DaniWeb is owned by Dani. The coding team is made up of paid employees (and possibly volunteers, although I don't know for sure). The content, for the most part, is produced by volunteers (like me), staffers (who produce news content, etc) and people asking questions. As the owner, Dani has the right to determine what content is acceptable. She does this personally, and through the actions of administrators and moderators. Consider the position of a newspaper. The editors have the right to determine which articles (and which letters) are acceptable for publication and which are not.

If anyone has a problem with how content is administered here they have three options

  1. modify their postings to conform to DanuWeb standards of conduct
  2. discuss it with those who manage the forums
  3. go elsewhere