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

If you mean expanding/collapsing long code segments it was answered here

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

I've never understood why the explicit forms of certain words offend people but the more politically correct (a phrase that offends me) forms such as f-bomb, c-word, n-word, etc. do not when by saying f-bomb you are basically still saying fuck. As George Carlin so aptly put it, "shoot is just shit with two os".

And while I am on my soapbox, you have the right to be offended by something, however, you do not have the right to label something as offensive. By labeling something as offensive you are applying a property to it when in fact you are stating your reaction to that thing and that reaction may vary from person to person.

Nick Evan commented: Yup. +0
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

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

Never have, never will. My dad suffered from emphysema after smoking for 40 years.

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

This has been asked and answered several times in this forum. Click on Search then enter application settings for the search string and vb.net for the forum.

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

I found programming a lot like the game of bridge. The bidding conventions can be complex but at some point a switch gets thrown in your brain and you understand without having to consciously think about it. With programming, it just takes practice and perseverence to get to the point where you can concentrate on the creative process itself without having to worry about each little detail. Or if you drive a car, the actual driving process becomes automatic and you stop focusing on each little thing and concentrate on the big picture. That is easier to relate to if you are 30 and not in your teens. I hope that makes sense.

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

Your first problem (and this is a biggie) is that you have included no comments with your code. It is hard to say if your code is doing what it is supposed to do when there are no comments saying what it is supposed to do.

Your second problem is that you have hard coded your entries. For the sake of developing the app, hard coding in a few entries is not a problem, but the way you have done it ensures that you have to add special code for every new entry. I suggest using a dictionary. The key would be the word, and the value could be a string array where item 0 is the part of speech and item 1 is the definition. For testing you can initialize the dictionary with a few words by

Private mydic As New SortedDictionary(Of String, String()) From {
    {"quick", {"adjective", "rapid"}},
    {"brown", {"adjective", "an earthtone colour"}},
    {"fox", {"noun", "a small carnivore"}}
}

but you would read the actual values from a database or file eventually. You can then load the listbox by

For Each word As String In mydic.Keys
    ListBox1.Items.Add(word)
Next

You wouldn't need a button. You could just select the word from the listbox by single clicking or by typing a word into textbox1. The code for the textbox1 event would be

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

    'As the user enters text into the textbox, check to see …
Begginnerdev commented: Yep! +8
joramkaku commented: Thank you. +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Sorry about that. Old eyes and interference from an overly affectionate cat. I must have misread MySql as MsSql. I'm not familiar with MySql but the principle is the same. You can prompt for the server name (and possibly credentials), then save it (once you verify that you can connect to the database) for future use.

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

I'm going to make a few assumptions

  • the database will always be MS SQL
  • the database name will never change
  • the security type will be integrated security

based on those assumptions, the only thing you should ever have to modify from installation to installation is the SQL Server Name. If the server type will always be SQLEXPRESS then you don't even have to modufy that. However, let's assume that the sever name will change. Iin that case you can create an application level settings variable and set it to "" by default. When the app runs you can test for this and prompt accordingly. Something like

serverName = My.Settings.ServerName

If serverName = "" Then
    'prompt for serverName and copy it into the connection string
    'if you can open a connection to the database then
        My.Settings.ServerName = serverName
    'else
        MsgBox("Could not connect to server " & serverName)
        Me.Close()
    'end if
End If

Then the next time the app runs it will automatically get serverName entered on the last run. If you are using a username/password for authentication then you may have to prompt for those as well.

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

Count your blessings. They talk about the mournful wail of a coyote or a loon at midnight. It does nbot compapre to the anguished cry of the third year university programmer who has just dropped a 500 card deck of unsequenced punchcards. I still get chills thinking about it.

<edit>that should have been "loon", not "loot"</edit>

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

honestly, I wonder whether that situation would also be the same if 'Iron Maggie' would still be dealing the cards

You mean like in the US where Republicans would like to see all sex education removed from the schools and birth control made unavailable to teens - a policy which has been proven to do nothing mut drastically increase teen pregnancy and the spread of STDs? Thatcher was Republican to the core.

stultuske commented: touché :) +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

made me a bit cynical I suppose

You'd never know it from your picture :-)

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

If you don't need to keep track of the index you can use a for-each loop. For example, if you have read the entire text file into a string array, lines(), you can process all of the lines by

For Each line As String In lines
    .
    .
    .
Next
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

The Split method will allow you to convert the line into a string array. You can split on any character but the default is a blank so if you start with

Dim line As String = "roivic lanoria ASRock 2.4 GHz Dual Core SSD 160 GB"

then do

Dim fields() As String = line.Split()

you get

fields(0) = "roivic"
fields(1) = "lanoria"
fields(2) = "ASRock"
fields(3) = "2.4"
fields(4) = "GHz"
fields(5) = "Dual"
fields(6) = "Core"
fields(7) = "SSD"
fields(8) = "160"
fields(0) = "GB"
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I expect certain things to be private. These are typically communications with financial institutions via https. I assume that everything else is, or could be, public. I assume that every email, every phone conversation (land line or cell), and even every snail mail letter can be laid open for examination by some person or agency. If I really need to communicate securely it's either face to face or encrypted email. But to be honest, most of what I say is not worthy of scrutiny.

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

Sorry. My mistake. The line should have been

Dim text() As String = Filter(System.IO.File.ReadAllLines(filename),email)
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Where there's a will, there's a way. Or as they say in Washington, if you can dream it you can scheme it.

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

You can read the entire file into a string array by

Dim text() As String = System.IO.File.ReadAllLines(filename)

If the file contains many lines and you only want one (assuming you can uniquely identify a line by, for example, the email address) you can do

Dim email As String = "heburn@YAHOO.COM"
Dim text() As String = Filter(System.IO.File.ReadAllLines(filename,email))

Assuming a match was found, your line would be text(0). You can split it by

Dim fields() As String = text(0).Split(",")

Then the fields you want would be

Trim(fields(1))
Trim(fields(8))
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

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

There is a good online tutorial here

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

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

The simplest method is

  • connect to the database
  • select records from one or more tables (query)
  • copy the data from the retrieved records into a display control

The type of interface you use will depend on the type of database. For example, if you are using a SQL database then you can use SqlClient (preferred). If some other source such as Access, Oracle, etc. you could use OleDB. Examples of both can be found here

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

I'm moving this from vb.net to ASP.net

Amitnamdeo commented: Thanks eakaglo, It appears your code could work perfectly but how to re-code it in VB.Net is my problem. +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

If you install the (free) Microsoft Sql Server Management Studio then you can right click a database or table and select "SCRIPT ...", then pick an option such as CREATE, DROP, etc and it will generate the required commands to the clipboard or a query window. Instructions on how to install are here.

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

They can't expect you to do double work

That hasn't been my experience.

Ketsuekiame commented: I definitely agree with this. Some weeks I've worked consecutive 16-18 hour days to meet deadlines. +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I reformatted your code. Notice how you are missing a few End If statements. Close your if blocks and you should be fine.

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

He's not at the "I don't know you" state yet. He forgets where to put things that have been in the same place for years (like the phone book) and he has trouble driving in that he doesn't remember how to get places (GPS helps a lot). And he can't follow complicated directions, but conversation and personality wise, etc. he's still the same person. He's ten years older than I am so I suppose that puts me at risk as well. I'll get back to you in 2023 to let you know how that turns out ;-P

LastMitch commented: You are gonna be fine ! =) +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I can't imagine that my father-in-law's colon cancer and my brother's Alzheimer's happened for a good reason. All the young boys buggered by priests and the children murdered in Newtown? Things happen for a reason. Perhaps the cancer was caused by a diet too high in fats and too low in fibre. The murders were possibly caused by too easy access to guns and too difficult access to mental health care. Reasons? Yes. But good reasons?

And sometimes sh!t just happens.

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

The @ values are just place holders. The names, such as @phone, don't have to be the same as (or even remotely close to) the actual fields in the database. It's just good practice to make them the same or similar. As I pointed out in the example, when using OleDb you use ? in the actual query and each successive AddWithValue replaces the next ? with the actual value you provide. When using SqlClient the placeholders in the query must have the same name as that given in the AddWithValue and the parameters can be added in any order.

If you were to code a query such as

qry = "INSERT INTO mytable (LastName, FirstName) VALUES(" _
    & "'" & txtLast.Text & "'," _
    & "'" & txtFirst.Text & "')"

and the name just happened to be Conan O'Brien then your actual query string would be

INSERT INTO mytable (LastName, FirstName) VALUES('O'Brien','Conan')

which would be invalid because of the single quote in the last name. If, however, you used

qry = "INSERT INTO mytable (LastName, FirstName) VALUES(@lname,@fname)"
cmd.Parameters.AddWithValue("@lname", txtLast.Text)
cmd.Parameters.AddWithValue("@fname", txtFirst.Text)

the resulting query would be

INSERT INTO mytable (LastName, FirstName) VALUES('O''Brien','Conan')

Notice how changing the single quote to two single quotes was done for you. Notice also how much easier it is to code the template query and much clearer it is when reading the code.

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

Definitely Stardock's ModernMix.

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

Tablename.replace("TextBox1.text");

That is not only syntactically incorrect, but it also is a meaningless statement.

  • what is Tablename
  • what is the text that you are replacing
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

The SQL command (you didn't specify what type of database) to create a table looks like

qry = "CREATE TABLE [xxxxxxx] (                      " _
    & "  [LastName]   varchar](50) NOT NULL,         " _
    & "  [FirstName]  varchar](50) NOT NULL,         " _
    & "CONSTRAINT [PK_xxxxxxx] PRIMARY KEY CLUSTERED " _
    & "   ([LastName](Asc))                          " _
    & ") ON [PRIMARY]"

so to create the query string you could do

qry = qry.Replace("xxxxxxx",TextBox1.Text)

then execute that query.

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

If life gives you lemons just say they are apples and sell them on Fox News.

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

So some moron out there decided to start a this site sucks thread, basically poking the bees' nest with a stick for fun just to provoke a response and you all jumped right in. Do you really expect to accomplish anything? I prefer to just ignore comments like this unless they occur in other threads where I can either downvote them, if they are relevent to the thread, or delete them if they are not.

<M/> commented: thank goodness you ended this thread +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

The second Full Metal Alchemist series was much better than the first. A few of my favourites were

  • Death Note
  • Trigun
  • Samurai Champloo
  • Monster
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

To start with, you'll declare the array as

Private intTemps(6, 1)

where the row numbers range from 0 to 6 and the columns from 0 to 1 (giving you 7 rows and 2 columns). To input the data you will have to prompt for two values for each of the seven rows so that looks like

For row As Integer = 0 To 6

Next

For each iteration you will have to prompt for (and validate) two values. The first value goes into intTemps(row,0) and the second into intTemps(row,1). Take it from there.

siaosituimoloaublood commented: Thank Rev. I will start on it and post what I got..Thank You +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

@happygeek - You missed an apostrophe? The horror. Obviously that totally invalidates all of the other content. Good thing there weren't further errors or I might have had to equate you to Hitler (because, as you know, some of Hitler's writings contained typos).

Sorry. I accidentally turned on Fox News and it takes a while to detox.

Echo89 commented: Haha, good one., +2
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Why not just separate textboxes for first and last names?

Begginnerdev commented: Best solution. (Not knowing the problem( If any) ) +8
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

If you are using Access the correct syntax is

SELECT * FROM table WHERE datefield = #datevalue#

otherwise use

SELECT * FROM table WHERE datefield = 'datevalue'
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Considering your apparent obession with achieving stats like Top Members by Activity Points Today and your prior endorse me and I'll endorse you signature, I agree that a little fishy is appropriate here. Most of us prefer quality posts over quantity and a scoring system that reflects that. As I've stated before, there is a big difference between Twitter and DaniWeb.