zachattack05 70 Posting Pro in Training

I have searched high and low for an answer to this question and the answers I have found don't generally apply to what I am looking at and was hoping someone might have some suggestions.

I have a form that is bound to a dataset that retrieves its data from a stored procedure. The controls are bound using a table adapter and a binding source.

The form contains many table adapters and binding sources but only one dataset and I'm finding out that in order to do what I want to do, a large drawn out process might be what needs to be done to achieve this.

Basically what I am looking for is a way to place a little asterisk "*" in the title bar of the window when the user makes a change to the data displayed to indicate that the data needs to be saved.

My problem is 2 fold:

1. Finding a method (preferably one that doesn't require me to loop through the entire dataset) that would indicate a change occured to a specific table.

2. Finding an event (preferably just one that I wouldn't have to apply to each and every possible control that the user can edit) that would perform the task above (#1).

This seems like it shouldn't be as difficult as getting the changes for an entire data set using the .HasChanges() method and looping through potentially multiple irrelevant changes when I am only looking …

zachattack05 70 Posting Pro in Training

It depends on what type of database you are using for the stored proc aspect.

This looks like a decent resource for MySQL (which is really all I use).

As for the optimizing, I would put that on hold and just fetch 1 record at a time as the user clicks them. Once that's working we can take it from there :)

I'll take a look at that.

Thanks for the help! I really appreciate it.

zachattack05 70 Posting Pro in Training

skatamatic, any suggestions for good reading material on the subject?

zachattack05 70 Posting Pro in Training

Cameronsmith63, the 4 columns was just an example.

I wanted to keep the sql commands in sql mostly for security and because some of the methods the application uses requires inserting, updating, deleting and selecting records across multiple tables. With the stored procedures, sending one piece of data to a stored procedure can propagate it anywhere it needs to without sending multiple queries.

Besides, saving the procedures on the sql server allows upgrades to the application on one workstation and not another. It's easier, in my mind, for backwards compatibility, but I could be wrong.

zachattack05 70 Posting Pro in Training

skatamatic, honestly...I don't know.

My experience with stored procedures is EXTREMELY limited. Outside of the query designer I've only modified one stored procedure manually, and surprisingly it worked the first time.

When I ask this, I'm not asking for you to volunteer anything, but how difficult would it be to implement something like what you suggest? Given my limited skill-set with these types of queries of course. Is this something relatively simple or complex?

I like your idea, and from what I have read, stored procedures can be very powerful tools, which is why I am trying to use them when appropriate. It's just hard to wield a 15 kilo sword when your 5 years old. I need to read more about these things, do you have any suggestions on good reading material on stored procedures?

zachattack05 70 Posting Pro in Training

That's a good point gusano79, I'm just worried that I would need to create so many different stored procedures, some of which retrieve data from the same tables for several different reasons, and a procedure for each reason seems overkill.

I could also see it from the other standpoint of going back 6 months later, reviewing the stored procedures and saying, huh...why aren't we using x, y and z columns with this?

I dunno, maintaining an application is a huge job by itself, anything to make it easier, I am all for!

One other question if you don't mind.

Assuming the same scenario above, if I have a table of say contacts or whatever, and I have a listbox on the left of the form and the selected contact information on the right; technically one query, requesting ALL of the data could easily populate both the listbox and the information for each in just one trip to the server, basically a "Give it all to me!" kinda query. But is it best to do that if the contact table is 20 columns and say 6000 rows? Or, is it better to send one request for the listbox to just get names or whatever to display, and each time the user clicks a contact name, send a separate request to the server for just that contact's information?

I can see how the second option has a huge performance advantage, but, I see it being slightly harder …

zachattack05 70 Posting Pro in Training

So, the question is, if I have a table on a SQL server with 20 columns, and I need to retrieve just 4 columns for a form, and I am using stored procedures to do most of my queries, should I create a stored procedure to retrieve just the 4 columns, or is it okay to retrieve all 20 and just ignore the 16 I don't need?

I am curious about CPU overhead with this AND network traffic of course if queries end up being many rows.

I ask because I'm worried about maintaining a database with so many stored procedures, that when a situation arises where a table (or whatever) changes, I could potentially have to go back and fix a lot of them, I'm trying to avoid that.

Any thoughts?

zachattack05 70 Posting Pro in Training

Thanks for your reply Philippe.Lahaie!

Are there any downfalls of using such a method? I've considered this exact method, but wasn't sure if there were any issues with using such a method?

zachattack05 70 Posting Pro in Training

Quick question.

A few of the commercial/closed source applications I use contain an external exception handler or crash catcher and I am wondering if anyone has ever implemented something like this and would be willing to discuss the use of such a method of exception handling?

Basically the way it appears to work is, when an application runs another application also runs separately but monitors the first watching for crashes. When an exception occurs that causes the first application to take a nose dive, the second application "catches" the exception, displays the standard "Sorry, this application died, here is some information you probably can't use...do you want to send this error to our tech support staff with a short description of what you were doing when the application died?" If the user says yes, the crash-catcher generates a text or some other type of object file that the user can either electronically transmit to the technical support staff at the company that produced the software via the internet or if no internet connection is available at the time of the crash, it saves the file to disk to be quietly transmitted later on when an internet connection is available or for the user to email to the tech support people.

Obviously the goal of any application is to handle any exception quietly and to make the user's life easier, but hey, let's face it, sometimes things are missed or overlooked.

So, I'm wondering a few things...

zachattack05 70 Posting Pro in Training

I have a databound combobox and I need to get all of the ValueMember values from each item in the combobox. I'd prefer to not change the selected item in the combobox to do this, since each time the item in the combobox changes a few events are triggered that wouldn't need to be.

Is there a way to just get the array of ValueMembers without a loop?

Nevermind, unless someone has a better solution, this seems to work:

foreach (DataRowView x in theDataBindingSource.List)
            {
                int xx = (int)x["MyValueMemberColumn"];
                // Do Stuff...
            }
zachattack05 70 Posting Pro in Training

I have a databound combobox and I need to get all of the ValueMember values from each item in the combobox. I'd prefer to not change the selected item in the combobox to do this, since each time the item in the combobox changes a few events are triggered that wouldn't need to be.

Is there a way to just get the array of ValueMembers without a loop?

zachattack05 70 Posting Pro in Training

Momerath,

As usual, you made my life so much easier. I don't know how you do it. I wish there was a way I could pay you back for all the help you have given me! If I manage to sell my final product I'll make sure you get something out of it :)

Thanks a ton! I was practically crying over that one for a few days, you can only stare at the screen so long before you just give up...thanks! It works perfectly!

zachattack05 70 Posting Pro in Training

As an addendum:

I am creating a stored procedure here to accomplish this task if that's of any help. My knowledge of SQL stored procedures is EXTREMELY limited. Beyond what the Query Designer offers, many things are over my head or I just don't have knowledge of them. If there is something special that can be done in a stored procedure to achieve this I wouldn't even know where to begin and would love to hear what you might have to offer in that area.

zachattack05 70 Posting Pro in Training

Sure!

Here's the current setup and some sample data. Also, this morning in my first post I gave the wrong table names but I doubt it matters. Anyway, the tables and data:

Table: Contacts

| ID |
------
| 1  |
| 2  |


Table: AccountContacts

| LocationID | ContactID |
--------------------------
| 1          | 1         |
| 1          | 2         |
| 2          | 2         |
| 3          | 2         |


Table: AccountLocations

| ID |
------
| 1  |
| 2  |
| 3  |
| 4  |

Okay, so a sample query would be to list out any contacts not associated with a given "LocationID"

So, if I want to know about LocationID 1, the output should be null because LocationID 1 has contacts 1 and 2 associated with it and since those are the only contacts in the contacts table, LocationID 1 has all the contacts.

If I use LocationID 2, the output should be ContactID 1.

If I use LocationID 3, the output should be ContactID 1 also

and finally, if I use LocationID 4, the output should be ContactID 1 and 2

Attached is an image of the table diagrams if it's of any help.

As it stands right now, the query you gave earlier and all of the ones I've tried, when given the LocationID 1, the result is ContactID 2, and if given LocationID 2 or 3, the result is ContactID 1 and 2.

It's making me crazy! Is it a bad table design or am I just missing something?

zachattack05 70 Posting Pro in Training

Hmmm
That doesn't seem to work either. I still get the same result.

I know there has to be a way to do this.

zachattack05 70 Posting Pro in Training

Hmmm...

That's clever! I'll give that a shot!

Thanks!

zachattack05 70 Posting Pro in Training

I'm lost on this one.

I've got 3 tables involved here. An Accounts table, AccountsContacts table and a Contacts table.

The AccountsContacts is a junction table between the two.

The key columns for the tables are:

Accounts: ID
AccountsContacts: AccountID, ContactID
Contacts: ID

I need a way to select from the contacts table all of the contacts that do NOT belong to a specific account.

The problem is, that since one contact can potentially be part of many accounts, by filtering by AccountID, I can get duplicate contacts and potentially contacts that are already a part of the account, simply because they belong to an account that I am filtering to.

So, what I was wondering...

Is it possible to first, uniquely select all rows in AccountsContacts based only on the ContactID, and THEN filter out the AccountID?

When I do this with Access it's a piece of cake, just create a query and use that query in another query. But I'm creating a stored procedure here, and I'm kinda lost.

Any suggestions?

zachattack05 70 Posting Pro in Training

Kamilacbe,

I still think you might be confused, but it's okay, it's probably me explaining it poorly.

I really have two questions. The goal is not to save data to the data source (well at least not necessarily), I know how to do that; the goal is to get a value that already exists in the data source (SQL in this case) in a bit field to be bound to a label that when bound doesn't say "True" or "False" but instead says "Male" or "Female" or in the case of a null bit value "Unspecified."

The second question is, for a combobox, is there a way to set a "SelectedValue" for each item in the combobox without binding the combobox to a datasource? Can the values be entered manually so that when the underlying data source is updated, and the user has selected "Male" from the combobox, the SQL statement doesn't pass the string "Male" or the integer value 1 to the server, but instead passes the boolean value "True."

I know there is a way to do this in code, I can achieve that without any issues, the question is can this be done with the IDE or is the best/only way to implement this by code alone?

zachattack05 70 Posting Pro in Training

I'm only really interested in using labels and comboboxes. The check and radio buttons I can figure out, it's just the combobox and text label I can't.

zachattack05 70 Posting Pro in Training

I have a Bit field (On/Off; True/False) that I would like to bind to a label and ComboBox, but I can't figure out how to have them display anything other than True or False. I'd like something like "Secure" "Unsecure" or "Male" "Female" but the text "Secure" corresponds to say, True and Unsecure False etc...

Any suggestions on how to successfully achieve this?

zachattack05 70 Posting Pro in Training

I'm not using Linq, I can't stand it, but I could check for the data first, I'm just worried about speed with something like that. I'll check that out! Thanks for the suggestion!

zachattack05 70 Posting Pro in Training

I'm curious about something.

If I have a listbox that is databound and a filter is applied to that listbox based on the value in a combobox, what would be the best way to handle the null reference exception thrown when the form loads or the filter changes and everything is filtered out. Right now I just have a "IsLoading" and "IsClosing" bool value that I change in those two events and just have a simple if statement to basically ignore the exception if either of those values is true.

But I'm not sure if this is the best way to handle this. I keep thinking that if a method is throwing an exception and you just "filter" the exceptions like I am doing and ignore some, it could be a problem later.

Any suggestions/thoughts?

zachattack05 70 Posting Pro in Training

I still don't get it. Does that mean a item in the listbox can have 3 values? A displayed value, a selected value and a value member value?

zachattack05 70 Posting Pro in Training

Long time no post! I hope everyone's well!

I'd appreciate some input here on this one...

I still, even after reading the MSDN documentation on the Listbox and ListControls, have no clue what exactly these properties are for.

I'm assuming the SelectedValue property, when accessed, returns the "value" of the item in the list that is selected, like the listbox might show employee names, but the real "value" of the items is the employee number or something; I think I get that, but ValueMember?

I thought that the ValueMember was used if you bound data to the listbox, the ValueMember was the column (or whatever) that the SelectedValue got it's value from, but that doesn't seem to be true, considering in a databound listbox, you can select a column name for the SelectedValue property and it works, even if you leave the ValueMember set to "None"

Could someone explain what these two properties really are, in simplistic terms, but not too simplistic, the MSDN site achieves that already.

zachattack05 70 Posting Pro in Training

Not yet, I have been working on a different part of the application. I'll be revisiting that tomorrow morning perhaps.

zachattack05 70 Posting Pro in Training

Meh, I'll figure it out. I can't get it to upload.

I'll just keep playing around until I figure it out. I'll probably just end up breaking it up into 2 steps for my own sanity.

zachattack05 70 Posting Pro in Training

I can't get the project to upload, I'll try again later

zachattack05 70 Posting Pro in Training

I could try, but the problem is that the data is being saved to a SQL server, unless you have that installed and the same database it wouldn't work.

I'll try when I get a minute and I'll post it.

zachattack05 70 Posting Pro in Training

Am I wrong in thinking that the Table Adapter Manager does all of this? I was under the impression it did.

What I am doing has worked before, but for some reason it's not now.

In fact, I have a form in the same project that does the same thing, but this one isn't working. I think its because they are both NEW records, not existing ones. I don't need to update the data, I need to create two new related rows in two different tables.

I think I need to divide it up, I can't assign a FK to a row if the PK doesn't exist in the first row, so when I go to save it, the key doesn't exist, so it doesn't save it. I'm just going to keep playing around with it. I'll figure it out :)

Thanks for the link, I'll look at it, but I don't think all of that is necessary, though I could be wrong.

zachattack05 70 Posting Pro in Training

Its the code generated by VS:

this.Validate();
            this.accountParentsBindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.suiteData);

However, there are two tables, the PK is located in accountParents, and the FK is located in accountBranches.

I need to add a record to both using that relationship, but it will only save the accountParents data, not the branch data. I've tried adding this.accountBranchesBindingSource.EndEdit(); and even switching them around and saving one before the other, nothing. I get a FK constraint violation if I try to save the accountBranches first, but if I have the "EndEdit" on both, it doesn't matter. Nothing.

It's making me nuts!

zachattack05 70 Posting Pro in Training

No problem.

zachattack05 70 Posting Pro in Training

Try WriteLine instead of Write. Or try writing "\n" for a new line.

zachattack05 70 Posting Pro in Training

Sure, just include the "Export to XML" feature for the user if they really want that.

zachattack05 70 Posting Pro in Training

XML works, but I avoid it like the plague.

XML files are bloated for the sake of "human readability."

I always use straight up binary serialization. You could always include a "export to XML" feature :)

zachattack05 70 Posting Pro in Training

The first thing I ever programmed was a magic 8 ball :)

I guess it depends, you could scour source forge for an open source project that needs help (though I think a lot of that is C++ not C#, and not usually .NET) or try Google Code for the same.

Have you tried client/server stuff? If you want a headache and lots of head scratching that will make you learn, socket programming can be fun (and frustrating) if you have a network to play on.

You could also try CRUD development, and create a program that stores data, analyses it and charts it etc...

Some other generic ideas:

* A journaling program that uses rich text, encryption to keep entries secure and multiple users.
* A program that analyses vehicle gasoline performance based on mileage, tire, oil and other maintenance.
* A program that plays Netflix movies (Netflix API and Developer Network)
* A MP3 player
* A video chat program
* A video player
* An image editor
* A web browser

Just some ideas :)

zachattack05 70 Posting Pro in Training

thines has a good suggestion.

If you are going to be holding many different pieces of data I would recommend delimiting the data in some fashion or otherwise structuring your file so that there is a "table of contents" so to speak so you can find where certain data is.

Unless it's absolutely necessary to store the data in a text file, you could serialize your data which might be easier.

zachattack05 70 Posting Pro in Training

I'm having a problem with using the table adapters to accomplish this and was wondering if someone might know of something I could be doing wrong.

The scenario is this:

Adding a new record to the underlying SQL database in this case requires that both a record exist in TableA and TableB. TableA holds the "One" and TableB holds the "Many" in this case.

The form I have is a Wizard style form that prompts the user for multiple pieces of data required to make these records.

All of the data is saved for TableA, but completely dropped from existance with no error displayed for TableB.

I can't figure this out...I keep thinking it has something to do with the PK. At the time of save, the PK for TableA hasn't been set, so it can't create the relationship to TableB because the PK doesn't exist yet. At least that's my theory.

The solution (though not very attractive to me) is to break the wizard into two steps, prompt for TableA data and then TableB data and saving the data between steps to the database. I don't like this solution though because it just complicates things if the user decides to cancel the wizard in the second step and not complete it, or the network drops and the user closes the form without completing the wizard. With everything on one page and not sent to the database until the step is completed (the "wizard" …

zachattack05 70 Posting Pro in Training

Nevermind!

I downloaded Open Office and their text editor can save to HTML :)

Works like a charm!

zachattack05 70 Posting Pro in Training

Thanks to Antenka I have located the HTML Help Workshop to create a Help system for my software.

Problem: writing HTML code is a heck of a lot more tiring than I expected. Does anyone know of a WYSIWYG HTML editor that only does the basics (fonts, tables, images etc...) and nothing fancy.

HTML isn't hard to write, it's just repetitive and it seems to be taking longer than it should.

I'd appreciate any suggestions.

zachattack05 70 Posting Pro in Training

If you want the letter variable to have an empty value you can use:

string letter = string.Empty;

or

string letter = "";
zachattack05 70 Posting Pro in Training

Threads are rather complicated and difficult to grasp at first but once you get the hang of it, it's a piece of cake.

I would read this entire E-Book, but for what you are asking about I would definitely read the Basic Synchronization section.

Mutix is one way of doing it, but there are many.

You can read the entire E-book starting here. I highly recommend it.

zachattack05 70 Posting Pro in Training

Is this is that you're looking for: Microsoft HTML Help 1.4 SDK? :)

Was that included with VS?

I downloaded the editor and installed it and it said something along the lines of "this computer has a newer version of HTML Help already installed"

I never remember installing it. Hmmm...

I guess this is it. Looks like the newest version and should work with Windows...now to figure out how to do it :)

Thanks!

zachattack05 70 Posting Pro in Training

Does anyone have a link to a good article or guide on creating help files that work with Windows XP, Vista and 7?

I've used a program in the past to create help files, but it was a demo product and quite costly (and if I recall poorly supported). I was hoping there was something released by Microsoft that was simple to use so my application can have help links in it.

Any help (ironic) on creating help would be great!

zachattack05 70 Posting Pro in Training

I disagree with the introduction in that article.

A good splash screen is quiet, simple, free of large graphics and "crayola box colours" and only shows itself if necessary.

I would say if your application takes less than 2 - 3 seconds to open the "Parent" form, there is no need to have a splash screen.

I would open the main form as quickly as possible and load everything else in the background so the user can immediately begin using the application instead of waiting for the splash screen to disappear and the main screen to start.

Another option is to start a timer on your load method, if the timer elapses 2 or 3 seconds and not everything is loaded...have the timer start a splash screen, that way the users with fast computers dont waste resources and time loading a loading screen...it would only show itself if it needed to.

Just my 2c worth :)

zachattack05 70 Posting Pro in Training

Does the user click a button on the actual windows form or the website form before moving to the next item in the listbox?

If the user clicks a button on the winform, that's simple, use a button click event to move down the listbox to the next item, if there is no next item, move to the first one again (if that's what you want).

If it's a button on the website form they click to advance...I'm not sure, I never use the browser control.

See the ListBox.SelectedItem property and the ListBox.SelectedIndexChanged event.

zachattack05 70 Posting Pro in Training

Panels are okay, just remember though, the anchor is only for the the control's parent container. So...if, for example, you have a form with PanelA and a label control LabelA inside that panel, when you set the anchor on the label, it will adhere to the PanelA rules.

I attached an example to show what I mean.

In the example, you can see that the label ignores the size of the window even with the anchor set. It does that because the anchor is relative to the panel, and the panel is set to Top, Left for both. If I changes the panel to "Dock Fill" the form, or if I changed the anchor of the panel, the label would react differently.

Honestly, I find the programming logic, the code writing or whatever you want to call it, MUCH easier than form design...I HATE messing around with layouts...it's so frustrating.

zachattack05 70 Posting Pro in Training

The label at the bottom is probably moving because the anchor for it is set to "Top, Left". Try changing it to "Bottom, Left, Right" or something along those lines to keep it in place.

The calendar is probably having the same problem. Maybe set it to "Top, Left, Right"

If you already have the anchor set correctly, the next question I would ask is, are you using any layout tables, panels or anything like that?

zachattack05 70 Posting Pro in Training

Hello Guys, I am building an application using C# as a front end(VS 2008).
I have a main form which contains a main menu and other controls like labels, calendar etc.. the main form I am talking about starts as full screen, my problem is when I drag/drop/edit controls in design mode and run the application, the controls are not in the same place as i putted them in design mode. [i.e] I placed a calendar in design mode in the center of the form, and another label as a footer, so when i run the application i found the calendar and the label went up few inches up.

Any help would be appreciated.

Can you post a screenshot of the problem and any code that you think might be suspect?

If you are using a MDI, the menu might move off of your form and onto the parent form which could make it look different.

zachattack05 70 Posting Pro in Training

Not really 100% sure I know what you are doing...

But, the load function only runs once, when the form is first loaded, after that it won't run again unless you specifically call it from some other method or event.

Look into timers if you are trying to capture images using a set interval.

zachattack05 70 Posting Pro in Training

Hmmmm I'll check into that!

Thanks!