ChrisHunter 152 Posting Whiz in Training Featured Poster

You need to bind the DataGridView to a data source

Have a look at this tutorial

ChrisHunter 152 Posting Whiz in Training Featured Poster

Apparently it's easier to learn C# if you already know Java, than it is to learn Java if you already know C#.

I've been told it's because C# is a younger language so it was created to close to be a slightly higher level language than Java.

I don't know how true that is but I personally found C# easier than Java.

As DJBirdi said though it's been debated to death.

ChrisHunter 152 Posting Whiz in Training Featured Poster

I've just had a little look and I'll be acquiring myself a copy of that!

Thanks again.

ChrisHunter 152 Posting Whiz in Training Featured Poster

Spot on @pritaeas that's worked a treat.

Linq is new teratory for me.

Thanks again.

ChrisHunter 152 Posting Whiz in Training Featured Poster

What is the best way to get the object, within a list of that object type, that has the highest ID number?

I've been trying to figure it out and I can manage to get the highest ID number but not the object containing that ID number.

Any help would be massivly appreciated,

Thanks.

ChrisHunter 152 Posting Whiz in Training Featured Poster

Always will be too but the more you learn the better it gets.

ChrisHunter 152 Posting Whiz in Training Featured Poster

Unless human1 and human2 will never be used outside of MakeReference() you should define them outside of the method:

    public class myHuman
    {
        string name;
        int age;
    }

    public class myClass
    {
        public myHuman person1;
        public myHuman person2;

        public void MakeReference()
        {
            person1 = new myHuman();
            person1.name = John Key;
            person1.age = 31;

            person2 = new myHuman();
            person2.name = Keil Carpenter;
            person2.age = 24;       
        }
    }

Like sepp2k said the new keyword mean you're creating a new instance of what ever is to the right of it.

ChrisHunter 152 Posting Whiz in Training Featured Poster
  1. 16 in collage but most of the course was written work or MS Access DB so really started at 19 in uni.

  2. C# and SQL because I haven't tried much else.

  3. I did because I've always found it hard to consentrate when reading or listening. I always hated education but stuck with it and I'm glad I did. It paid off in the end.

ChrisHunter 152 Posting Whiz in Training Featured Poster

Take it from one of the slowest learners in history, you CAN make a career out of it. You just have to want it enough and don't expect to be a top dev straight away. Plenty of vets in the industry will tell you they still don't know everything.

I would say start of on what ever you're best at and once you've got your foot in the door and are quite capable in that area, start learning new stuff.

As for knowing what you want to do yeah personally I'd say you should really have an idea by now but you've still got time to figure it out.

Does your course not sepecialise in a particular field? Mine had a web route, a desktop app route and a general IT, route which you could choose to follow after the first year. The first year was a taster of all 3 to help you decide.

Nothing is set in stone though. My friend and I went to collage and uni together, did the same desktop development route at uni but now he's a web dev with a bit of mobile apps and I stuck to desktop dev but I'm going to try to move into web too in the next 12 months.

Also remember Rome wasn't built in a day...

ChrisHunter 152 Posting Whiz in Training Featured Poster

If you could post the code that you have for the log in function we can have a look to try and help you out.

ChrisHunter 152 Posting Whiz in Training Featured Poster

There is a law that says its legal to shoot a Welsh person with a bow and arrow inside city walls after midnight.

Also In Liverpool it is illegal for a woman to be topless in public except as a clerk in a tropical fish store...

I work in liverpool... all of a sudden I feel the urge to buy a gold fish on my dinner hour :s

ChrisHunter 152 Posting Whiz in Training Featured Poster

"The best way to predict the future is to create it" - Peter Drucker

ChrisHunter 152 Posting Whiz in Training Featured Poster

Los Angeles’ full name is “El Pueblo de Nuestra Senora la Reina de los Angeles de Porciuncula”.

ChrisHunter 152 Posting Whiz in Training Featured Poster

I'm only 24 and I don't use Skype but I know I'm old because I think the best thing about going to a party is the food! I'm only 24 but when I were a lad we were always the first to the buffet and first to go for seconds.

I'm going to an 18th on Saturday and I bet non of the teenagers eat any of the buffet... I just don't get it

ChrisHunter 152 Posting Whiz in Training Featured Poster

Your naming conventions aren't clear. It's considered bad practise to use use special charactor like _ to separate the words within a field name. Instead simply capitalise the first letter of each word (i.e. DevicePersonId and not Device_Person_id).

Also when you give a table an alias within an SQL statement it should be something meaningful. For example a more meaningful alias for dbo.tempdevicelogs would be tdl (the first letter of each word in table names should be capitalised too i.e. dbo.TempDeviceLogs).

If you want to join tables that have a common field you should used the JOIN key word rather than doing nested select statements if possible.

In all honesty I can't work out what you're trying to do.

If you list what fields you want, the table you want the field from and under what conditions I might be able to help you out.

What is Date1?

ChrisHunter 152 Posting Whiz in Training Featured Poster

Could you mark this thread as solved please? That way people with the same problem will know this thread may contain the solution they're looking for.

Cheers.

ChrisHunter 152 Posting Whiz in Training Featured Poster

What code do you have so far?

ChrisHunter 152 Posting Whiz in Training Featured Poster

No problem, I'm glad I could help.

ddanbe commented: Yes, great help! +15
ChrisHunter 152 Posting Whiz in Training Featured Poster

Try value.ToString().Substring(0, 10). If the object passed in as value param isn't a string it won't work. What will you pass in as value param?

You might also need to change the string format to include - instead of /.

ChrisHunter 152 Posting Whiz in Training Featured Poster

I had a similar problem a couple of weeks ago and this was my solution

DateTime.ParseExact(value.Substring(0, 10), "dd/mm/yyyy", null).Date.ToShortDateString();

You should just have to change the format string ("dd/mm/yyyy") to "yyyy/mm/dd".

Hope this helps...

ChrisHunter 152 Posting Whiz in Training Featured Poster

I'd go with Watsonsimler's suggestion because it reduces the chance of the user accidentally clicking the delete button in a row they don't want to delete.

You can't also have a checkBox cell in every row and a single delete button on your form (not in the data grid view). This will let the user select multiple rows to delete at once. If you use the checkBox option you can add buttons to do other functions such as exporting the selected rows to an Excel document or something like that.

Sorry I went off on one then but it's another option you could think about which could reduce the amount of work you'll need to do if something like that became a requirement in the future.

ChrisHunter 152 Posting Whiz in Training Featured Poster

I'm with happyGeek on this one. I watch the odd TV show like Men Who Jump Off Roofs or The Island but the majority of it is un watchable. I have to endure The Only Way Is Essex and Big Brother...

ChrisHunter 152 Posting Whiz in Training Featured Poster

I wouldn't mind getting a tattoo from this fella, they look amazing and the detail is unbelievable!

This Guy

blackmiau commented: uh, yeah! +0
ChrisHunter 152 Posting Whiz in Training Featured Poster

What have you managed to do so far?

Do you need to display your entire database in 1 datagrid view or do you just need to display a particular set of data?

Unfortinately there won't won't be many people rushing to give you finished code, you have to show some evidence that you've attempted it yourself first.

I'd be happy to help if I know what you've done...

ChrisHunter 152 Posting Whiz in Training Featured Poster

A couple of songs/ artists I'm hammering at the minute:

  • Mr Probz - Waves (Robin Schulz remix)
  • Sigma - Nobody to Love
  • Tove Lo - Stay High (Habits Remix)
  • Shift K3Y - Touch
  • Duke Dumont
  • Clean Bandit

and of couse Jack Johnson!

ChrisHunter 152 Posting Whiz in Training Featured Poster

I can't unfortunately blackmiau it's my firend's work so I don't own it.

Wales never dissapoints diafol. I go camping in near Porthmadog and at Llyn Gwynant campsite every year.

We broke down over looking Llyn Clywedog. We had to wait for 3 hours before the breakdown service came but I could think of worse places to get stranded!

ChrisHunter 152 Posting Whiz in Training Featured Poster

This is a still of me, taken from my friend's GoPro, just after his bike broke down on him during a ride in the middle of Wales. It's not a cruiser but thought you might appreciate it @blackmiau.

2fcdb3ed5b0354c7b35018c583b0b5fa

ChrisHunter 152 Posting Whiz in Training Featured Poster

Music on a BSC IT course? I've never heard of that.

It depends on the place you study and the type of person you are. My University wasn't the greatest because they invested heavily in the sports department and not IT but it was still worth while.

My advice is to make sure you take the time to understand what you're being tought, you'll be a more confident programmer at the end of it all. There will always be people in your class who don't listen and rely on others to do their work that but quite often they don't graduate.

Also don't forget to ask questions if you don't understand something, your tutors will always be willing to help. There will always be someone here at DaniWeb that will be willing to help you too, as long as you're willing to try, myself included.

Mya:) commented: :) +0
ChrisHunter 152 Posting Whiz in Training Featured Poster

I have one of those... I'm a software engineer for an insurance brokers. What type of job do you want? did you specialise in anything during your degree?

I specialised in software development so that's the path I followed professionaly.

ChrisHunter 152 Posting Whiz in Training Featured Poster

Contrary to popular belief, the notion that goldfish have a memory span of just a few seconds is false. It is much longer, counted in months.

... I guess I don't have the memory of a goldfish.

ChrisHunter 152 Posting Whiz in Training Featured Poster

I went through a similar patch just before the new year @diafol. I decided it worth regretting not having done the things I wanted to.

I went out and bought myself the motorbike I'd wanted since I was a nipper and had been putting off for years. I'm planning to learn how to surf this summer too and looking into possibly working in New Zealand for at least 12 months.

As for tattoos, I've always wanted one and I had vouchers to get one, but I couldn't decide what I wanted to get and didn't just want a tattoo for the sake of getting a tattoos. I'll get one eventually, possibly on my side or back.

diafol commented: Great +0
ChrisHunter 152 Posting Whiz in Training Featured Poster

No problem, glad I was of some kind of help.

ChrisHunter 152 Posting Whiz in Training Featured Poster

Sorry I didn't see your reply. Ignore my last comment if it's working.

Check the table names and field names are correct. It could be a case of a capital letter is needed instead of lower case.

ChrisHunter 152 Posting Whiz in Training Featured Poster

Comment out the contents of your if statement (DON'T DELETE IT) and paste this into it:

deleted = dataGridView1.Rows[selectedindex].Cells["MovieID"].Value.ToString();
cmd3 = new SqlCommand("ALTER TABLE dbo.MovieCopy DROP CONSTRAINT FK_MovieCopy_Movies",cnn);

cmd1 = new SqlCommand("Delete From MovieCopy where movieid=@movieid",cnn);
cmd1.Parameters.AddWithValue("@movieid", deleted);

cmd2 = new SqlCommand("Delete From Movies where movieid=@movieid", cnn);
cmd2.Parameters.AddWithValue("@movieid", deleted);

cmd1.ExecuteNonQuery();
cmd2.ExecuteNonQuery();

cmd4 = new SqlCommand("ALTER TABLE dbo.MovieCopy ADD CONSTRAINT FK_MovieCopy_Movies FOREIGN KEY (MovieId) REFERENCES dbo.Movies(MovieID) ON DELETE CASCADE", cnn);

dataGridView1.Rows.RemoveAt(selectedindex);
dataGridView1.Refresh();

Try that. I've put the delete for the MoveCopy first so that the primary key in the Movies table can be deleted without any problems (hopefully).

I've also put the dataGridView1.Rows.RemoveAt(); at the end so that the ID of the movie that is being deleted is the selected movie.

Let me know how you get on.

ChrisHunter 152 Posting Whiz in Training Featured Poster

Try deleting the record from MovieCopy table, before deleting from the Movie table, so that the reference to the Movie table record doesn't exist.

Also you might need to move dataGridView1.Rows.RemoveAt(selectedindex); and put it below cmd4 = new SqlCommand.

By the looks of it you're deleting the record at "Selectedindex" which removes that row and the row at "Selectedindex" is now the row below meaning MovieID won't be the ID of the row that has just been removed from the datagridview.

Hope this helps.

ChrisHunter 152 Posting Whiz in Training Featured Poster

Move dataGridView1.Rows.RemoveAt(selectedindex); and put it below cmd4 = new SqlCommand.

By the looks of it you're trying to get the MovieID from a row that doesn't exist at anymore.

Hope this helps.

ChrisHunter 152 Posting Whiz in Training Featured Poster

Take a look at this link.

In your case you might just need to set the value of pbx1_1.Image to the value of pbx1.Image, within the pbx1_MouseClick method.

Good luck...

ChrisHunter 152 Posting Whiz in Training Featured Poster

Have you used Google? Have a look at this too. You might be able to compress the image. I've never used them myself though so it's just a suggestion.

There is a Visual Studios plug in called ReSharper. The full version costs but I think there is a trial version. It helps you minimise you're code and make it as efficient as possible by using LINQ where possible, removing white spaces and removing redundant code among other things.

It might not dramatically reduce your project size if your code is already super efficient but it could be worth a try.

NOTE: It will overwrite Visual Studios shortcut keys if you don't tick the right box on installation.

ChrisHunter 152 Posting Whiz in Training Featured Poster

It's C# so this is the best place for it.

This is the only way I can think to do it using a loop...

double Total = Convert.ToDouble(numbers[0]);

for (int i = 1; i < numbers.Count(); i++)
{
    Total = Total * Convert.ToDouble(numbers[i]);
}

It would be the best way if you have a lot of numbers or the amount of numbers would change but if you only have a constant amount of about 4 or less number the way you have done it is good.

ChrisHunter 152 Posting Whiz in Training Featured Poster

For England I'd say Buckingham Palace but others might disagree.

ChrisHunter 152 Posting Whiz in Training Featured Poster

My suggestions didn't specify what method to put the validation in but only the validation. They are two different and clean ways to do the validation (which is what was asked), with the first being the best of the two.

Unnecessary clicks are bad practice.

Knight YUVA probably specified using a label for a reason. Highlighting an individual field using it's label, on a form full of fields, would be better than having a massage box for every field.

Saying that yes you're right about when the validation should be carried out (which helps me with a problem of my own).

If it were me I would use error provider controls, containing relevant error messages, which are shown, or not shown, as a result of the validation carried out within the textBox1_Validating() method.

Thanks.

ChrisHunter 152 Posting Whiz in Training Featured Poster

Yes just use string.IsNullOrEmpty(texBox.Text).

It returns true if the string is empty and false if it have charactors in it (including spaces).

So you could do:

label.Text = string.IsNullOrEmpty(textBox.Text) == true ? "please enter the part no " : " ";

OR

if (textBox.Text.Length > 0)
{
    label.Text = "please enter the part no ";
}
else
{
    label.Text = " ";
}
Knight_YUVA commented: 10 +0
ChrisHunter 152 Posting Whiz in Training Featured Poster

Your question is pretty hard to understand.

Do you want svs to repeat the value of TextBoxC1 and x to contain the value of TextBox1?

What is {MATH}?

What errors do you get?

ChrisHunter 152 Posting Whiz in Training Featured Poster

I'd say a minimum of 4 tables.

* Customers table
    - CustomerID (Int PK)
    - CustomerName (VarChar)
    - Address (VarChar)

* Products table
    - ProductID (Int PK)
    - ProductName (VarChar)
    - Cost (Float)

* Orders
    - OrderID (Int PK)
    - CurstorID (Int FK)
    - TotalCost (Float)

* OrderDetails table
    - OrderDetialsID (Int PK)
    - OrderID (Int FK)
    - ProductID (Int FK)
    - Quantity (Int)

Having the table structure above means 1 customer can have many orders and 1 order can have more than 1 of many products.

It will give you a more complete set of data if you are doing invoicing, stock taking or generating reports on how well products are selling and which customers are placing the most orders.

ddanbe commented: Nice & neat +14
ChrisHunter 152 Posting Whiz in Training Featured Poster

@Wael1988 by the looks of what you have studied you've know quite a few languages. I only know C#, Sql and a bit of VBA. I've worked with reporting services too but that's about it.

Experience with SharePoint is/was quite sort after when I was looking for a job 2 years ago but it's best to focus on two or three specific languages, such as C# and SQL, and use those as you're main selling points. This way you have the front end language with the C# and back end language with the SQL.

As you have suggested yourself the best way forward is to get as much development under your belt as possible. I'm in the same position as you I always forget what I've been studying.

Keep going, it's not easy but the more you do the easier it will get!

Good luck.

ChrisHunter 152 Posting Whiz in Training Featured Poster

watch this video, I don't know if it shows any code (I can't get on youtube in work). It should show you how to makes object move in C# and you can adopt that in your code.

I'm sorry but I'm not willing to help you any more, you're year two so you should know how to Google by now and that code is clearly copied.

Advice... Start work earlier, Google more and make friends with the best programmer in your class (they won't do the work for you but you can learn a lot from them).

ChrisHunter 152 Posting Whiz in Training Featured Poster

Cold chocolate fudge cake with vanilla ice cream every time.

ChrisHunter 152 Posting Whiz in Training Featured Poster

Hate the stuff! It makes everywhere look scruffy as hell, it gets every where and there's too many people who sound like a camel when they're eating it!

I got it stuck to my shoe twice last week.

I don't want to hear people chomping, it don't want to see what people are eating and I 100% don't want have to scrape it off what ever clothing it gets on, just brush your teeth or eat smint!

Screw it I'm moving to Singapour!

ChrisHunter 152 Posting Whiz in Training Featured Poster

What exactly do you want to know?

What code have you written so far?

What video are we supposed to be looking at?

ChrisHunter 152 Posting Whiz in Training Featured Poster

Welcome to DaniWeb helb,

You stand a better chance of getting C++ help if you post you questions in the C++ form but you also need to show that you've attempted the task yourself first otherwise you might struggle to get any helpful replys.

Have a go at Googling it, the calculator is a beginner's task in most languages so there will be plenty of examples for you to look at.