nmaillet 97 Posting Whiz in Training

You should show some effort in attempting this problem before asking for help. There's a good C++ tutorial at this site: http://www.cplusplus.com/doc/tutorial/.

nmaillet 97 Posting Whiz in Training

If you're specifically targeting Windows, you can use Visual Studio Express. If you want to support Mac and Linux as well, you'll probably want to go with MonoDevelop. There are a lot of IDE's out there, just Google it, same goes for quick tutorials on creating desktop applications.

nmaillet 97 Posting Whiz in Training

I don't know how to do that, teach me please

You would set that up in the constructor (or Form.Loaded event handler) with something like this:

textBox7.Tag = "First Name";
textBox7.Leave += textBox_Leave;
textBox8.Tag = "Last Name";
textBox8.Leave += textBox_Leave;
...

The Tag property simply holds any object. The Leave event is triggered whenever focus is taken away from the control (TextBox). This means any time the user navigates to another control, via the mouse or keyboard, the event is triggered. This will not implicitly check the conditions before any actions are performed however (such as a button click).

You can take a look at this article. It shows the built in validation logic for WinForms. You could handle the Validating event the same way you would handle the Leave event, but you could also call ValidateChilder() in the button Click event.

If you don't want to use that, you could setup a quick array in the constructor:

TextBox[] checkEmptyTB = new TextBox[] {textBox7, textBox8, ...};

Then iterate through them in the Button.Click handler:

bool empty = false;
foreach(TextBox tb in checkEmptyTB)
    if(tb.Text.Trim() == string.Empty)
    {
        empty = true;
        break;
    }
if(empty)
    MessageBox.Show("Please fill up all the required details.");
else
{
    ...
}

God Bless you all!

Isn't it a bit presumptuous to assume others believe in the same things you do?

nmaillet 97 Posting Whiz in Training

Give this a try:

        SqlDataAdapter dt = new SqlDataAdapter();
        SqlCommand command = new SqlCommand("select * from DVD where Name = @name", c);
        command.Parameters.Add("@name", SqlDbType.VarChar, 100).Value = txtName.Text;
        dt.SelectCommand = command;

Couple of things, first it should handle any encoding issues or data type mismatches since the parameter is defined (double check and make sure Name is varchar(100)). Secondly it should prevent SQL injections, according to this article. I haven't tested it out myself, but you may want to look into SQL injections if anybody else is going to be using this.

nmaillet 97 Posting Whiz in Training

You want to have a look at this thread. I don't have time to look at the solutions now, but they may be of some help.

nmaillet 97 Posting Whiz in Training

You can also use the AcceptButton property of the Form. This will however, capture the Enter key from any control on the Form. But, this generates the button's Click event, a mouse click or enter key can be handled in the same method.

nmaillet 97 Posting Whiz in Training

You'll want to take a look at the System.Xml namespace. As a starting point, you can call XmlDocument.Load(...) , and work from the XmlDocument object created.

nmaillet 97 Posting Whiz in Training

If you are using Visual Studio, I believe there are some project templates that aid in this. However, I have never used them. I have had some experience with office and Interop. You will have to add a reference to Microsoft.Office.Interop.Excel (with the correct assembly version; 12 I believe).

using namespace Excel = Microsoft.Office.Interop.Excel;
...
public static void Main(string[] args)
{
    Excel.Application app = new Excel.Application();
    Excel.Workbook workbook = app.Workbooks.Open("testing.xls");
    ...
}

Note that there are classes in this namespace, but C# will not work with these; stick with the interfaces. Also, if you are working in anything before .NET 4.0, you will have to use Type.Missing for all optional parameters, like:

Excel.Workbook workbook = app.Workbooks.Open("testing.xls", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
peter_budo commented: Question was asked in Java section not C#, so do not post irrelevant stuff -4