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

Learn your computing history. Linux doesn't do things the way it does to deliberately be different from Windows. Linux was developed by Linus Torvalds because he wanted a Unix system but couldn't afford the exhorbitant licencing fees. He developed Linux to be like Unix, which was around a very long time before Windows or even PCs. Unix was first released in 1969. Windows 3.0 was released in 1990. The Linux kernel was first released in 1991.

As for the configuration nightmares and having the OS sit in the background - I absolutely agree with you on that. I've been programming proofessionally for almost 40 years. I've tried to make the move to Linux several times and each time I just found the maintenance and configuration too time consuming.

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

If you do

Dim fields() As String = TextBox1.Text.Split("-")

assuming that you, in fact, have a date entered in the form YYYY-MM-DD then

fields(0) will contain the YYYY part
fields(1) will contain the MM part
fields(2) will contain the DD part

This will work even if the month and day parts do not have a leading zero. Then to do the math you can do

Diim diff As Integer = Now.Year - CInt(fields(0))
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

If you google it you get this

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

I'll move this thread to vb-4-5-6 if the OP requests it.

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

The first example you gave me had the columns

First column           Second column
12345678               12345678     
12578                  36894        
69782                  36548        
12547                  16974        
36894                  69836        
36548                  78954        
16974                  99789        
69836                  12578        
78954                  69782        
99789                  12547        
12347965               12578        
                       69782        
                       12547        
                       12345678     

I don't see how you can match these up. Column two violates the unique constraint as 12345678 appears twice, and 12347965 appears in column one but not column two. If, however, if we use the numbers in the second example, we can align them by

Dim col1() As Integer = {12345678, 12578, 69782, 12547, 36894, 36548, 16974, 69836, 78954, 99789, 12345677, 99789, 69836, 12345678}
Dim col2() As Integer = {12345678, 12578, 69782, 12547, 36894, 36548, 16974, 69836, 78954, 99789, 12578, 69782, 12547, 12345677, 99789, 69836, 78954, 12345678}

Dim i As Integer = 0

For Each num As Integer In col2
    Dim item As New ListViewItem
    If i < col1.Count AndAlso col1(i) = num Then
        item.Text = col1(i)
        item.SubItems.Add(num)
        i += 1
    Else
        item.Text = ""
        item.SubItems.Add(num)
    End If
    ListView1.Items.Add(item)
Next

That shows how to take the numbers and align them using a listview as output. Do you know how to get at the Excel data from vb.net?

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

That becomes a little more difficult. What are we guaranteed?

  1. are there always the same or more numbers in column 2 than column 1?
  2. are all of the numbers in a column unique?
  3. are all of the 8-digit numbers always present in both columns?
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Then you'll have to post what the output is because I don't know what you want to do to line things up. While you are at it, can you please post the exact format of the two excel files?

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

So you want to end up with

12345678      12345678    
   12578         36894 
   69782         36548 
   12547         16974 
   36894         69836 
   36548         78954 
   16974         99789 
   69836         12578 
   78954         69782 
   99789         12547 
12347965         12578    
                 69782
                 12547      
              12345678                
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

My two sons.

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

If you do a manual delete then you might want to use the registry cleaner feature of ccleaner to do the registry cleanup for you.

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

muslims aren't allowed to terrorize

Here's a news flash. Nobody is allowed to terrorize.

and you are to commit a major sin if you do terrorize

<M/> - You might be interested in this discussion that took place some tine back. Islam and logic

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

I've never use a Mac so I can't speak to that. I've used both Linux (several flavours) and every version of Windows except Windows ME and Vista. My impression is that Windows is more appropriate for your average user and Linux is geared more toward the techie. Like Harley's and Hondas. If you want to own a Harley you'd better be prepared to tinker and get greasy.

I did a lot of reading into the inner workings of the Amiga when I owned one (Amiga 1000). I wish it had become more mainstream. I'd like to see what it would have become by now. The features built into it (I'm speaking OS, not hardware) were amazing especially for the size. Very little duplication of code.

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

Maybe they can plea bargain him down from 23 to 9 consecutive life sentences in exchange for information on anyone else who may have been involved. Then someone in prison can shank him for all I care. I'm normally a compassionate person but I have my limits.

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

Consider it moved.

Begginnerdev commented: Thank you, Jim! +8
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I'm not suggesting this as the best way. I only offer it as one way. Set the KeyPreview property of the form to True then add the following handler

Private Sub Form1_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress

    If Asc(e.KeyChar) = 13 And Me.ActiveControl.GetType() = GetType(TextBox) Then
        SendKeys.Send("{TAB}")
        e.Handled = True
    End If

End Sub

If you press the ENTER key while you are in any textbox, the ENTER key effectively gets translated into a TAB key. Actually what happens is the ENTER key gets ignored and the app gets sent a TAB key. Same difference. You can take this example and modify it with various conditions. I'm sure there is a better solution but this should work until one comes along.

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

You can use shift-Tab to tab backwards through the controls.

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

If you don't know where she heard it and you can't confirm it as fact then just keep your racist statements to yourself. It might have been a Somali man. It might have been a Swede. It might have been Rush Limbaugh. It might have been anybody. That statement was only meant to cast aspersions against someone, or in this case some group. I've heard they arrested a suspect but I have no details yet. I'm not going to assume an organized conspiracy. I'm going to wait for the facts.

Mike Askew commented: Well said +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Sounds like a homework assignment. What have you done so far?

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

Without getting into all the other stuff, if you want to know the highest number in a column you can use the MAX function as in

SELECT MAX(PrinterID) FROM ...
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I try not to bring it up

Then don't. I think that going off half cocked and throwing around accusations with no evidence is exactly the wrong thing to do. It's an immature, knee-jerk reaction that will only cause more problems than it solves.

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

The preferred way is to use parameters. Because you are using MS SQL I will assume you are using SqlClient and not OleDb.

cmd.CommandText = "INSERT INTO PRINTERMAINT(PrinterName, PrinterNumber, PrinterLocation, PrinterAddress) " & _
    "VALUES (@prtName, @prtNo, @prtLoc, @prtAdd)"

cmd.Parameters.AddWithValue("@prtName", printName)
cmd.Parameters.AddWithValue("@prtNo",   printNo)
cmd.Parameters.AddWithValue("@prtLoc",  printLoc)
cmd.Parameters.AddWithValue("@prtAdd",  printAdd)
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I don't know about a book but the win32 API is documented online here

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

The following lists all of the subkeys under HKCU\Software

Dim key As Microsoft.Win32.RegistryKey = My.Computer.Registry.CurrentUser.OpenSubKey("Software")

For Each subkey In key.GetSubKeyNames
    Debug.WriteLine(subkey.ToString)
Next
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

VB will flag a problem if the variable is set inside another block. For example

Dim s As String

If x > 5 Then
    s = "bigger"
End If

Msgbox(s)

will indicate a problem because there is an execution path where s does not get assigned a value. I have had code where the variable absolutely will get assigned a value but the compiler could not figure it out. I generally do this to make the warning go away

Dim s As String = ""

If x > 5 Then
    s = "bigger"
End If

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

Click on Files and you should see the Upload Attachments panel appear below the edit window. Click on Browse then select a file to upload. Note, there is a maximum size of one meg so if your zip file is larger than that, try deleting any exe files in the project folder and rezip.

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

You are assuming that the filename contains only one ".". That is often not the case.

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

Please post the new code.

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

You can do an integer divide more simply by

intTotalAsterisks = intSales \ intASTERISK

And you don't need the if-then-else for the zero case. You can just do

Dim strAsterisks As New String("*", intTotalAsterisks)

Your indentation is extremely misleading. Redo it so that it is obvious which code belongs to which if-then-else block. You are calculating strAsterisks for each store in the loop but you don't add it to the listbox until after you leave the loop so it will just use the last calculated value five times.

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

Why learn an old version of something? Download vb.net 2012 and go from there.

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

You can select specific columns (by listing the column names) and you can select specific records (by using a WHERE clause) but you can't vary the columns within a query. You might want to consider redoing your tables. I don't understand your column names. For example, I would have thought a class would be something like "History" or "Chemistry". Instead you have form1, form2, etc. And I have no idea about Cooker or MalipoAda. tblStudents should contain static information about a student such as name, birthdate, address, phone. Each record would have a unique studentID which would be used in all other tables. A separate table would contain class info with one record per student per class. tblContributions needs further explanation. I have no idea what this is.

savedlema commented: Thanks Reverend. +1
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You can't select some columns for some records and not for others. All records have to have the same columns. You'll have to post the exact structure of the three tables for me to be more specific. An example of the output you want to see would also be a big help.

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

That's the thing about a preference as opposed to a hard and fast rule. If you have a style and you refuse to break it, even when it makes complete sense to do so, then you are an idiot. Your examples clearly warrant making an exception. There is consistency and then there is foolish consistency. Fortunately, very few of my if conditions span multiple lines.

A foolish consistency is the hobgoblin of little minds, adored by little statesmen and philosophers and divines. - Ralph Waldo Emerson

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

What looks more pleasing?

if (some condition) {
    true part
} else {
    false part
}

or

if (some condition)
{
    true part
}
else
{
    false part
}

I prefer the first form. I like a balance between white space and code crunching. If half the lines consist solely of opening or closing brackets then that means that much less information that can be presented at one time on a screen or a page. As my dad used to say, "there's a difference between scratching your a$$ and ripping it to shreds" so either extreme - too much or too little white space - makes the code harder to follow.

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

You don't put single quotes around field names. Because your names have embedded blanks try putting the field names inside square brackets as in [my field name]. When you say

SELECT myfield

what gets returned is the value of myfield for all records. When you specify a literal like

SELECT 'this string'

what gets returned is the string 'this string'. It's like the difference between "print the value of x" and "print the value of 5"

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

It would help to see the code you are using to add in the parameters in case there is a problem there, but for now try

 SQL = "SELECT s.FirstName, s.MiddleName, s.Surname, p.* " _
     & "  FROM tblstudents AS s, tblpayments as p " _
     & " WHERE s.studentid = p.studentid " _
     & "   AND p.class = @class"

The p and s are temporary aliases. They make for a lot less typing and a lot fewer typos.

 SQL = "SELECT s.FirstName, s.MiddleName, s.Surname, p.* " _
     & "  FROM tblstudents AS s INNER JOIN tblpayments as p " _
     & "    ON s.studentid = p.studentid " _
     & "   AND p.class = @class"

is functionally the same query

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

Background threads cannot access controls directly. They have to use delegates. They are not that complicated and you can see an example of how to do that here

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

Execute the query

SELECT @@VERSION

You'll get back something like

Microsoft SQL Server 2008 (SP3) - 10.0.5500.0 (Intel X86)   Sep 22 2011 00:28:06   Copyright (c) 1988-2008 Microsoft Corporation  Express Edition on Windows NT 6.1 <X86> (Build 7601: Service Pack 1) 
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

There is a good online tutorial here

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

There is something in place already. If you have email notification enabled then you will be notified when you are upvoted or downvoted (at least with a comment).

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
Dim qry As String = "insert into Department(DNo,DName,Manager,AddressL1,AddressL2,City,Telephone,E-mail)values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox8.Text + "' )"
Debug.WriteLine(qry)

Then copy the output and post it here. In any case, you should be using parameterized queries. See examples here

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

Just execute the following query

UPDATE mytable SET fld1 = RTRIM(fld1), fld2 = RTRIM(fld2)...

with the names of the fields you want to modify

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

If the field is of variable length then use nvarchar. Just make sure to do a Trim on the text when you patch in the parameter. What goes into the field is exactly what you tell it to. The spaces are there because they were in the original text field.

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

It's an option in your profile - Automatically Watch Articles I Post In

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

I assumed that the database name was Pay based on the name of the actual file. I also assumed that because you had specified Integrated Security=True that you were validating based on your current login username. Are you using windows authentication or SQL server authentication?

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

First of all, you should let SQL Server manage the location of your database and use the following connection string

Dim con = New SqlConnection("Server=.\SQLEXPRESS;Database=Pay;Trusted_Connection=yes;")

assuming your database name is Pay. Then use

con.Open()
cmd.CommandText = "SELECT Firstname,Lastname FROM Employee where Firstname = @Firstname and Lastname = @Lastname"
cmd.Parameters.Add(New SqlParameter("@Firstname", TextBox1.Text)) .Value = TextBox1.Text
cmd.Parameters.Add(New SqlParameter("@Lastname", Lname_txt.Text)) .Value = Lname_txt.Text
dr = cmd.ExecuteReader

If dr.HasRows Then
    While dr.Read
        Label4.Text = dr(0)
    End While
    MessageBox.Show("This Employee Does Exist!")
Else
    MessageBox.Show("This Employee Does Not Exist!")

It is possible that both Danial and Daniall exist in the table. I tried your code here and it returns the expected results. One more note - you should also do dr.Close() when you are done reading.

And to answer that actual question - using the query as you have set it up (with parameters) is good protection against SQL injection.

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

You didn't mention what post.

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

A dataset does not exist in the database. It is created in memory inside a running app. Same thing with a datatable. What exists in a database is stuff like tables, views, stored procedures, triggers, etc. As I recall you installed SQL Server Management Studio. If it is visible there then it can be deleted there.

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

seems to be fine now... any guesses?

One of the flay rod's apparently gone out of skew on the treadle?

Sorry. I got nothin'.

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

Not a problem. I removed the duplicate. I have Visual Studio 2010 ans MS SQL Express. As well, I installed the (free) MS SQL Server Management Studio. You can find instructions on how to install it here. The Management software greatly simplifies creating and managing databases.

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

For a large database you should go with MS SQL. I had to maintain an Access database for years that was not developed with ADO so porting it to SQL was too much trouble for the developer to consider. As a result, when the database grew beyond a certain point I had to repair it on a weekly basis.