kplcjl 17 Junior Poster

Help whom? The original poster is 3 years gone.
I certainly would be pissed at a control that didn't let me use the arrow keys, the backspace key, the delete key. Those are part and parcel of a numeric entry. What if the number is real? How about negative numbers?
Personally, I like to be told after the fact that I screwed up, not the machine going dead with no clue what I'm screwing up.

ddanbe commented: Good point! +15
kplcjl 17 Junior Poster

kimbula last posted 2 years ago, hasn't responded to suggestions since. Why would (s)he care about suggestions now? My suggestion 2 years ago avoids all the try/catch logic because it is encapsulated in int.TryParse. (Still need error handling, but number handling is built into the numbers themselves. Seems dumb to use anything else when built-in functionality comes directly from .NET.)

kplcjl 17 Junior Poster

EventHandlers are one form of a delegate.
ShapeValueChanged is the delegate.

The following is the subscription of the delegate to the Form1_ShapeValueChanged method:
ShapeValueChanged += new EventHandler(Form1_ShapeValueChanged);

The forms detects an event change and calls the event handler ShapeValueChanged which calls all the subscriptions to it. In this case, only one subscription.

kplcjl 17 Junior Poster

OK, you found a solution, but nobody suggested a delagate. I tried to build a puzzle solving code and display intermediate results and display them on my WinApp form. Didn't do a thing. Turns out, the form thread has to be idle to display changes and I wanted intermediate results not the final ones.

Now the puzzle solving app (PA) is completely separate from my form, so it can be run for any kind of UI. My form subscribes to the delegate and if it asks the PA to show intermediate results, the PA calls the delegate passing a byte array and a text array and then sleeps for the length of time the form asks for. (The PA will allow sleeping for an hour, the form will only ask to sleep up to 10 seconds.) The form wakes up moves the bytes and strings into text boxes and then exits. (Letting the form to sleep again. The sleep refreshes the text box displays.)

SoftwareGuy commented: Thank you for adding insight and an alternative to a problem, even after the thread was closed. +2
kplcjl 17 Junior Poster

All the replies to you have been based on reasonable assumptions based on what you said. Because you aren't clear on what you want, you force people to guess. I'm guessing based on your not liking the responses you have gotten.

I'm going to re-write your question and answer it. You say if the question is close to what you really want.

How do I get a column's values from one table into another table when the other table doesn't have the column defined?

(The difference? You are saying the schema of the other table isn't right. Why I think that's what you mean? Neither of the responses you got were acceptable.)

First off, you can't do this in one step. Use ALTER TABLE to add a column to the other table first. If the table has data already in it either this new column must be nullable or you supply a default value that can be overridden.

(You do specify column names in all of your existing queries, don't you? Otherwise, you probably just broke your existing queries.)

Second, you need to plan how you want the data from the one table put into the second table. You have two ways to do this: insert or update. With insert you need to figure out how to supply all the required columns in the table along with the new column's values. With update you need to figure out how you are going to join …

Knvn commented: Nice Attempt +1
kplcjl 17 Junior Poster

can another way through which UI thread remain running

You will never, ever, see a form respond to a form change while the form's thread is active. The form thread MUST be idle, for changes to be returned to the form's thread to act on them. The timer solution works because it is a delegate running independently of your form thread. (There is a bug in the given logic "if (++i > 199)" will stop at 199 just like your loop.) If you want the user to be unable to do anything until the count is finished, then use his first solution. If you want another way, this will work, but I bet you like it less than the timer solution.

1. Create a routine to handle updating of your label from the passed information.
2. Create a small class that has a delegate routine. A looping routine.
3. Assign your form routine to your delegate.
4. start the looping routine in a new thread.
5. In the loop call the delegate and then Sleep. Forget the Refresh, you don't need it.

PS. I have a combo box that picks between 10, 5, 1, 0.1, 0.5, 0.05, 0.01, and 0.0 convert that to an integer a 1000 times bigger and sleeps for that time. (I sleep for a maximum of 500 and increment up to the set time when it is bigger than that. When you sleep for 10 seconds, it is agonizing to …

kplcjl 17 Junior Poster

sorry - I read this wrong - I thought you wrote: It's not COMMON (I left out the "UN") but I was talking about instantiating a class this way not inheritance.

I am obviously very new to this stuff and struggling to learn. Hopefully it will click as I persist...
I appreciate your examples and your time. All very helpful..

It wasn't my comment, but it is a sentiment I agree with. (not uncommon, a double negative, that's bad English because it leads to misunderstandings like yours, but the sentiment was clear to me because this term is unfortunately common.)
When you code, you model. The human model is a common one used in examples because everyone understands it. It's also a great example because the model changes over time. When I was born, if you were male and adult, you had to be a Man. Today, it's not that obvious. It's not obvious to me that someone born male is still male. It is obvious to me that someone born male can be a Woman. Every criteria that you can use to prove is still male can also be used to prove people born female aren't female, so they must be male. How you implement the model is the trick.

kplcjl 17 Junior Poster

I purchased a book that included an evaluation version of 2008 enterprise. I had downloaded SQL 2005 express and had tried to download 2008 which said it succeeded and I was left with 2005. I checked the OS list of supported ones. XP professional is on the list. XP home isn't. Without any expectation of succeeding, upgrading 2005 failed pretty quickly because it couldn't write to a dll file on my CD reader.
OK, uninstalled 2005, tried a fresh install of 2008. I got a lot further and spent a lot of time preparing the installation. It installed the programs but every one of them failed.
I went upstairs to a PC I totally hate, booted it up, saw I lost my virus protection, solved that by pulling my network cable, checked the OS (OK), drive space (barely OK), put the CD in... Nothing.
My CD drive isn't connecting with the computer.
AUUUGGG
OK, I don't expect help, I'm just venting. (and dreading the download time to install SQL 2005 express again.)

sknake commented: i hope some rep cheers you up +6
kplcjl 17 Junior Poster

The TextBox class dosn't support the Transparent
But I think you can get the same Effect by setting the backColor property for the textbox into the same color for form and ste the text box border to none

textBox1.BackColor =  this.BackColor;

How could that get the same effect? The default backcolor is NOT transparent. This works for me:

using System;
using System.Windows.Forms;
public class TransparentText : Form
{
	private TextBox Trans_tbx ;
	public static void Main(){Application.Run(new TransparentText());}
	public TransparentText(){
		Trans_tbx = new TextBox ();
		InitializeObjects();
		ResumeLayout(false);
	}
	private void InitializeObjects() {
	this.SuspendLayout();
        this.Trans_tbx.BackColor = System.Drawing.SystemColors.InactiveBorder;
        this.Trans_tbx.Location = new System.Drawing.Point(56, 48);
        this.Trans_tbx.Multiline = true;
        this.Trans_tbx.Name = "Trans_tbx";
        this.Trans_tbx.Size = new System.Drawing.Size(440, 400);
        this.Trans_tbx.TabIndex = 0;
        this.Trans_tbx.Text = "test 1";
        this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
        this.ClientSize = new System.Drawing.Size(544, 502);
        this.Controls.Add(this.Trans_tbx);
        this.Name = "TransparentText";
        this.Text = "test Transparent Text";
        this.TransparencyKey = System.Drawing.SystemColors.InactiveBorder;
	}
}
faeophyta commented: This helped a lot, thanks! +0
kplcjl 17 Junior Poster

I second Tom's suggestion to use parameters. This assures the types are compatible and takes care of formatting as well.

Are you sure the datetimepicker will pick an exact date and time that you want? It's possible the query will never find the record even if it is formatted correctly.

kplcjl 17 Junior Poster

It is preferable to execute a procedure over letting your code have ANY access to tables directly.
I pulled the following script from help files looking up ExecuteNonQuery. Note the same type of query with SQL objects is available as well.

Public Sub CreateMyOdbcCommand(myExecuteQuery As String, _
myConnectionString As String)
    Dim myConnection As New OdbcConnection(myConnectionString)
    Dim myCommand As New OdbcCommand(myExecuteQuery, myConnection)
    myCommand.Connection.Open()
    myCommand.ExecuteNonQuery()
    MyConnection.Close()
End Sub

This is a simple query without parameters, but you can build the command with parameters as well. There are tools that will set it up for you as well. Read up on how ADO.NET works. Or you can build your command:
str = "Exec dbo.mysproc @custid=" & id.Tostring()
Again, using the built in commands is much better because it builds a type safe interface between the parameters you want to use and the values passed. For instance it would take "Exec dbo.mysproc @custname=xxyy", but it would fail to execute because xxyy wasn't quoted.

TomW commented: I agree overall and think you offer good advice but I do have a (respectfully) differing opinion about calling exec in a statement. A former bad practice that I used to do myself until proven as not being optimal. +1