Click here to Skip to main content
15,886,362 members
Home / Discussions / C#
   

C#

 
Questionhow to update listView on all clients machines when new data was added? Pin
kai-best4-Sep-10 5:06
kai-best4-Sep-10 5:06 
AnswerRe: how to update listView on all clients machines when new data was added? Pin
Not Active4-Sep-10 5:41
mentorNot Active4-Sep-10 5:41 
GeneralRe: how to update listView on all clients machines when new data was added? Pin
kai-best5-Sep-10 2:23
kai-best5-Sep-10 2:23 
GeneralRe: how to update listView on all clients machines when new data was added? Pin
Not Active5-Sep-10 2:59
mentorNot Active5-Sep-10 2:59 
GeneralRe: how to update listView on all clients machines when new data was added? Pin
OriginalGriff5-Sep-10 4:12
mveOriginalGriff5-Sep-10 4:12 
GeneralRe: how to update listView on all clients machines when new data was added? Pin
Not Active5-Sep-10 5:07
mentorNot Active5-Sep-10 5:07 
GeneralRe: how to update listView on all clients machines when new data was added? Pin
OriginalGriff5-Sep-10 5:15
mveOriginalGriff5-Sep-10 5:15 
AnswerRe: how to update listView on all clients machines when new data was added? Pin
OriginalGriff4-Sep-10 6:05
mveOriginalGriff4-Sep-10 6:05 
I agree with Mark - except I would use a application settings file for the connection string, rather than a constant. That way, you don't have to change the software when you do go to multi-user, just the app.settigns file. You can also test your software on an off-line database while the production one is untouched.

As for the SQL Injection - Mark is spot on. Look at the MySqlCommand.AddWithValue method for details. It makes life a lot simpler than string concatenation.

ListViewItem item = new ListViewItem("" + rdr[0]); // by the way why it doesn't work if i omit "" + ?
item.SubItems.Add("" + rdr[1]); // i have to add empty string for it to work...
item.SubItems.Add("" + rdr[2]);
It doesn't work because DateReader returns an object - you have to cast it to an appropriate data type. For example
ListViewItem item = new ListViewItem((string) rdr[0]);
item.SubItems.Add((int) rdr[1]);
item.SubItems.Add((float) rdr[2]);
By adding the empty string, you are forcing an implicit string conversion via the default ToString implementation. This may not be what you want in all cases...

When it comes to updates, and distributing them, I am afraid you will have to poll for them as Mark sugested. Use a timer, so you aren't looking all the time, and probably set a table with a last update column. Then you only have to read a single row in order to tell if you are up to date. Nasty, but better than reading an entire table.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

GeneralRe: how to update listView on all clients machines when new data was added? Pin
kai-best5-Sep-10 2:29
kai-best5-Sep-10 2:29 
AnswerRe: how to update listView on all clients machines when new data was added? Pin
kai-best5-Sep-10 2:44
kai-best5-Sep-10 2:44 
GeneralRe: how to update listView on all clients machines when new data was added? Pin
OriginalGriff5-Sep-10 4:10
mveOriginalGriff5-Sep-10 4:10 
GeneralRe: how to update listView on all clients machines when new data was added? [modified] Pin
kai-best6-Sep-10 3:22
kai-best6-Sep-10 3:22 
QuestionRule Engine Pin
Shubhabrata Mohanty4-Sep-10 3:45
Shubhabrata Mohanty4-Sep-10 3:45 
AnswerRe: Rule Engine Pin
dan!sh 4-Sep-10 4:40
professional dan!sh 4-Sep-10 4:40 
QuestionUpdating a progress bar in a loop Pin
Keith Vitali4-Sep-10 2:25
Keith Vitali4-Sep-10 2:25 
AnswerRe: Updating a progress bar in a loop Pin
Henry Minute4-Sep-10 3:25
Henry Minute4-Sep-10 3:25 
GeneralRe: Updating a progress bar in a loop Pin
Keith Vitali4-Sep-10 4:26
Keith Vitali4-Sep-10 4:26 
AnswerRe: Updating a progress bar in a loop Pin
PIEBALDconsult4-Sep-10 3:47
mvePIEBALDconsult4-Sep-10 3:47 
GeneralRe: Updating a progress bar in a loop Pin
Keith Vitali4-Sep-10 4:46
Keith Vitali4-Sep-10 4:46 
Questionhow many open connection is recommended to leave - in sql server 2008 Enterprise Edition Pin
Gali19784-Sep-10 1:23
Gali19784-Sep-10 1:23 
AnswerRe: how many open connection is recommended to leave - in sql server 2008 Enterprise Edition PinPopular
OriginalGriff4-Sep-10 1:45
mveOriginalGriff4-Sep-10 1:45 
AnswerRe: how many open connection is recommended to leave - in sql server 2008 Enterprise Edition Pin
PIEBALDconsult4-Sep-10 3:42
mvePIEBALDconsult4-Sep-10 3:42 
AnswerRe: how many open connection is recommended to leave - in sql server 2008 Enterprise Edition Pin
dan!sh 4-Sep-10 4:38
professional dan!sh 4-Sep-10 4:38 
GeneralRe: how many open connection is recommended to leave - in sql server 2008 Enterprise Edition Pin
PIEBALDconsult6-Sep-10 16:45
mvePIEBALDconsult6-Sep-10 16:45 
QuestionInstaller doesn't register file types' icons properly. Pin
WebMaster3-Sep-10 10:07
WebMaster3-Sep-10 10:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.