hericles 289 Master Poster Featured Poster

Oh I see. If you want to return a lot of data use a dataadapter

SqlCommand cmd = new SqlCommand();
cmd.Connection = cnn;
cmd.CommandText = "Your sql statement";
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
adapter.Fill(dt);

You can remove you cnn.Open() and cnn.Close() as the DataAdapter takes care of that itself. You end up with the data you extracted from the database in the dataTable.

Hope that helps.

hericles 289 Master Poster Featured Poster

You could always change your code to be:

Catch ex As Exception
MsgBox(ex.Message)
Finally

to actually see what exception is being caught.

hericles 289 Master Poster Featured Poster

Is this project involving databases or do you simply need two Acccount instances created that communicate?
If the later you need to create your Account class with methods (getter and setters) that alter the current amount (which will be a class variable).
Create the two classes, initialise each with a certain amount and then call your withdraw and deposit methods.

public class Account
        {
            private float balance;
            public void Deposit(float amount)
            {
                balance += amount;
            }

            public void Withdraw(float amount)
            {
                balance -= amount;
            }

            public void TransferFunds(Account destination, float amount)
            {
                this.Withdraw(amount);
                destination.Deposit(amount);
            }

            public float Balance
            {
                get { return balance; }
            }
        }

And then access like so

Account target = new Account();
target.Deposit(300.00F);
public void Withdraw()
        {            
            float amount = 200.00F; 
            target.Withdraw(amount);
        }

You were in luck, I had an old test case example lying around:)

hericles 289 Master Poster Featured Poster

I think correct indenting is easier to understand than the numbers beside them and is a habit you should get into. Other coders will expect to see it.

hericles 289 Master Poster Featured Poster

One last thought on the topic. The SelectedItem object will give that error if you haven't actually selected an item before clicking on the buttons. So if you are clicking on Button5 or Button6 before clicking on an item the program will crash with that error.
Either have one item selected as default when the page loads or include a check to see if ListBox1.SelectedItem is null when checking the SelectedItem.Text

hericles 289 Master Poster Featured Poster

My bad, I just did a test project cause I haven't used VB.Net for a while (mainly use C#). It works with just one = which means something else is going on to cause your first error.
Object reference not set to an instance of an object normally means the object has not been created yet but I can't see how that is the case in your code as the ListBox1 is defined in the page.

hericles 289 Master Poster Featured Poster

You need to use == there as you're not setting ListBox1 to be "", you're checking the value.
Sorry I should have noticed that before.

hericles 289 Master Poster Featured Poster

Hi,
I think you need to use ListBox1.SelectedItem.Text.
I assume you're getting stuck here:

If ListBox1.Text = "" Then
MsgBox("A file needs to be selected...!")
End If

ListBox1.Text isn't the best option. ListBox1.SelectedItem.Text matches the actual value selected from the list.

hericles 289 Master Poster Featured Poster

Hi,
Clear out your listbox before you start adding the files to it

ListBox1.Items.Clear()
For Each file In ftpFiles
   ListBox1.Items.Add(file)
Next

This empties the list of the previous inputs so when you reload on the page refresh the previous items aren't doubled up. ListBox1 holds its contents through a page post back.

Hope that helps,

hericles 289 Master Poster Featured Poster

Hi,
What browser are you seeing this in? I just copied this code and tried it in IE, FF and Chrome and it looked OK in all of them.

hericles 289 Master Poster Featured Poster

Hi,
I wouldn't make hitting the enter key tab the focus to the submit button because all the user is going to do is hit the enter key again (being unaware that the use of it is not allowed in the textbox) thereby submitting the unfinished textbox.
You could look at why the carriage return is causing an issue and deal with that or parse the text when it is being submitted to replace carriage returns with something else (<br /> if you're doing something in a browser).
The problem with your code above is that it isn't telling the carriage return to not be entered, its saying move focus AS WELL AS enter carriage return.

hericles 289 Master Poster Featured Poster

Everytime I have had this error (usually moving my project to a production server just like you did) it is always because I haven't updated the connection string in the web.config to point to the new database. Or it could be the database hasn't been created on the production server.

hericles 289 Master Poster Featured Poster

Hi,
It sounds like you are on the right track. The session_start and session_end in the global.asax file can be used if there are any other tasks you want to achieve e.g. saving user data to a database (time on site, pages viewed, etc).

hericles 289 Master Poster Featured Poster

Hi,
If you add a Global.asax file to your website you can access methods for session_start and session_end. They are managed by the server, not the browser. For example the Session_start method is called the moment a new user requests a page from the site. The timeout period can be specified there and the server monitors the inactive or total time spent by the user on the server.
I hope that helps,

kvprajapati commented: Good explanation. +9
hericles 289 Master Poster Featured Poster

Hi,
You'll need to use session timeout for the idle feature. You can set that in the Global file.
For the log out feature you can use session variables. When the user logs in the logged_in variable is set to true, on log out you make it false. Then each page as it loads can check the status of logged_in and act accordingly. I'm assuming you've done something similar to this already otherwise a user could bypass the login screen by typing the url of the home page into the browser.
Hope that helps.

hericles 289 Master Poster Featured Poster

Are you accessing the ToString() property of the textbox? If not, you're not working with the string value itself, you're trying to alter the TextBox control. Are you trying to subtract two numbers or are you working with text input?

hericles 289 Master Poster Featured Poster

Hi,
KISS huh?
Question depends on the type of questions theyare answering although any solution requires saving the answers they've entered in some way. If its multi choice or short answer you could save each answer to a database under the user ID and then retrieve them when they log back. Or, if you're keen you could save the answers as XML files but the database solution is easier.

Setting up passwords isn't someting that can be explained in enough detail here. I suggest finding an article online and reading it.

By blocking copying I assume you mean disable printing and print screen and the like. To be honest I've never had to try it and I'm not sure a foolproof method exists. Maybe someone else has advice on that part of it.

Hope that helps,

hericles 289 Master Poster Featured Poster

I'm assuming the name is www.roommatefinder.com (or similar suffix) but you don't actually mention it. You mention the admin person getting confused with the 'double R' and there is no double R in that URL so I'm not even sure that's the right one.
If it is roommatefinder I don't see any real problem with it. Its easy to remember and uses normal spelling. You might consider including a '-' (to make it roommate-finder) but most people don't expect hyphens in URLs (my opinion at least).

Hope that helps,
Hericles

hericles 289 Master Poster Featured Poster

Hi,
If you're drawing the data for the first two columns out of a database, just add a third column into the SQL query that combines the two. Then databind the gridview to the resulting table.

E.g.
Select exam1, exam2, SUM(exam1 + exam2) as total from table;

If you need to do it after the query for some reason, add a new column to the resulting dataTable from the query and then loop through inserting the sum of the two columns together. Then databind the gridview once that is done.

Check this article out for an example of the code:
http://www.codersource.net/dataset_preparing_manual_data_addition.html

Hope that helps,