|
SeMartens wrote:
Second: The way you validate username and password is not really the safest one.
Safest? It's flawed badly!
Of course you can only log in as the last user in the db, because that's when your while loop ends.
Even when and if your username and password is correct for some other user, and you set the count variable to 1, the next time the loop.. .erm... loops it will change it back to 2. Unless it's the last record.
To the author:
But yeah, the way you do it is really ugly, though. Imagine you had 500k users. Would you put all the records in the memory then, and iterate through them?
Ever heard of the "WHERE" clause for T-Sql? ;>
var question = (_2b || !(_2b));
|
|
|
|
|
Haha, its only in the early stages of development lads, just like I am a novice at this.
Could you guys provide me with examples as to how I can do it better.
PS. I am creating a winforms application only, no ASP.NET or nothing. Its a standalone app.
Thanks
|
|
|
|
|
An Enigma wrote: 2. Once logged in, how will the application know which user is which and to update the logged in user's particular entries?
Well this part sort of says: "I can't tell the difference between a winform and a webform", with all due respect.
Each instance of your "application" will have to be installed on each computer you will ever want to use it on, right? Then when you log in, just keep your user id, name, or shoe-size in a global variable than you can access later.
Bah, go crazy, make it a static!
And use it in your PARAMETERIZED queries in the WHERE clause ;>
What's your ChangePassword class supposed to do, again?
var question = (_2b || !(_2b));
|
|
|
|
|
Woah, this is too much unknown info for me there mate.
The change password class changes the password for the user logged in.
Are there any examples I can look at for what you are saying?
|
|
|
|
|
|
First up split the database connection and authentication of the application out from the authentication of the users.
Create a SQL standard login for you app. Now you application has na identity that it can use to connect to the database regardless of the user.
Create your own user table where you store all the data to authenticate you users (userid, password - encrypted, expiry date and any groups he user may belong to in your app, email, names, address, phones, etc etc)
You login form can now talk to your database (using it's own ID) and query the user table to check the userid and password, if the login is valid then pass the user to the main form.
I think there is an example login project here on CP if you search for it.
|
|
|
|
|
Thanks for the reply Mycroft.
The way you described it in your post sounds like what I am looking for, would you know the name of the project?
Thanks
|
|
|
|
|
Heres a little light reading[^] for you.
It is after all a fairly large and critical area of developing. try wandering through some of these articles and pick the ones most relevant to you.
|
|
|
|
|
Hi all
i have a c# application on minimizing i place it into the system tray.now when the application is in the system tray and the user shutdown the system a log file should be written into a temp folder in c:\ i tried using onshutdown() it is not working, it would be better to say i dont know how to use it in my application plz help me
|
|
|
|
|
Handle the form's closing event. FormClosingEventArgs has a CloseReason property. If it is CloseReason.WindowsShutDown , write log file.
|
|
|
|
|
thanks a lot. it works fine
|
|
|
|
|
Hey, im working on a project and i have to get the name(header text) of selected column in my listbox or textbox from datagridview, when i select any column it shows the name of that column in textbox or listbox.. i'll be very thankful to if you guys kindly help me out in this matter..
im trying to use the code on DataGridViewHeaderClickEvent
"textBox1.Text=dataGridView1.SelectedColumns.ToString();"
|
|
|
|
|
Try this
private void dgData_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
string s = (sender as DataGridView).Columns[e.ColumnIndex].HeaderText;
}
|
|
|
|
|
Thank you so much
it worked & really helped me,
well what if i want to get just all my column header names in a listbox?
|
|
|
|
|
Try:
private void FillColumnNamesListBox()
{
this.namesListBox.Items.Clear();
foreach (DataGridViewColumn col in this.dataGridView1.Columns)
{
this.namesListBox.Items.Add(col.HeaderText);
}
}
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
thank you so much henry
it worked (Y)
|
|
|
|
|
Hello, in my windows form app, i have a function that acts as a loop. This function calls other functions and runs through the code.
Example:
Loop()
{
one();
two();
three();
four();
and so on
}
How can i create a 1 second wait time in between each function within Loop()?
There will be many function calls within this Loop() so setting a timer_tick to call a specific function wont work for the rest.
It cannot be Thread.sleep as this is a single thread app.
Thanks!
|
|
|
|
|
Hi,
Plaese try this
Loop()
{
one();
System.Threading.Thread.Sleep(1000);
two();
System.Threading.Thread.Sleep(1000);
three();
System.Threading.Thread.Sleep(1000);
four();
and so on
}
|
|
|
|
|
Hello
Sorry but you did not fully read my question.
Cannot use Thread.Sleep because it is a single thread app.
|
|
|
|
|
Why? Thread.Sleep works also with a single thread application: it blocks the current thread.
It looks to me that you are omitting some details that could be useful for us to help you, can you explain more what your problem is?
|
|
|
|
|
Ok, I thought people would understand that since it is a windows form application, that i would not want it to seize up with a Thread.sleep.
My mistake.
Thanks for the response.
|
|
|
|
|
Oh, ok.
Then you can not do what you want with a single thread: use a BackgroundWorker to run your function.
|
|
|
|
|
Will that work with an ActiveX com object? Because i tried to do A separate thread for the loop and the webbrowser control on my app broke.
|
|
|
|
|
I've used a BackgroundWorker in an ActiveX object written in C# and loaded in a WebBrowser control before, and it worked.
You have obviously to make sure to use Invoke when updating the UI in your separate threads, though.
|
|
|
|
|