Ketsuekiame 860 Master Poster Featured Poster

I've been in front of a computer since 1989 :D

Ketsuekiame 860 Master Poster Featured Poster

Tea snobs ho! o/

I drink imported dried Jasmine tea or green tea.

Ketsuekiame 860 Master Poster Featured Poster

@scarwars; don't try and do something very complicated. Look at the task and think of something simple. Unless it's something like an obfuscation competition in which case make sure no one ever understands it, not even you :)

Always ensure you design something within your ability to do within the timeframe. It's all well and good coming up with the best design EVER. But if you can't do it then what's the point? :P

Ketsuekiame 860 Master Poster Featured Poster

Extremely bright and sunny today, temperature is 1C - 11:00am

Ketsuekiame 860 Master Poster Featured Poster

What we know as the internet now will disappear, eventually. The internet from back in the 90's has already vanished.

It will probably end up the way of many other things and sold to you in packages. It will become a forum for big businesses and professionals. Amateur websites will become a thing of the past. You will be sold the internet in packages, much like how Sky TV sells you bundles of channels. You will get the "Social Networking" package. The "Funny Websites" package and a "News" package. An avid backer of this model is Richard Branson.

Legislation is driven by business and/or the need to control information. "Freedom" is irrelevent; it hurts profit margins :P

Ketsuekiame 860 Master Poster Featured Poster

It's not so bad anymore, not after the therapy anyway ;)

Ketsuekiame 860 Master Poster Featured Poster

Your button control will have a Left and Top property along with a Width and Height property. When you type in your co-ordinates, ensure that the X position is inside the leftmost position plus the width and that the Y position is inside the topmost position plus its height.

You should iterate a loop that checks each control on the form. foreach will help here. When you find the control in that position, you can check if it is a button. If it is, you can perform a click to run the code the button would execute.

Mike Askew commented: Most help you will get, short of us writing the code for you. +6
Ketsuekiame 860 Master Poster Featured Poster

Ensure that you're using at least .net 3.0 and add a reference to System.Windows and System.Web

Ketsuekiame 860 Master Poster Featured Poster

You forgot to put .Value on your SelectedCells line. :)

Not entirely sure what you're trying to do on line 17 though...?

Ketsuekiame 860 Master Poster Featured Poster

Cast it to DateTime and call ToOADate()

eg. ((DateTime)row.Cells[DATEColumnIndex].Value).ToOADate();

You should probably do a null/empty check first :)

EDIT: You should also set the number format of the cell in Excel to be Date format.

((Range)ws.Cells[CurrentOrderRow, 3]).EntireColumn.NumberFormat = "YYYY/MM/DD";

Note you can do it individually or the entire column like I have shown. If you do the entire column, you don't need to do it every single iteration, just once when you're finished and before you save.

Ketsuekiame 860 Master Poster Featured Poster

You're updating CurrentRow, not CurrentOrderRow, so it's over-writing the old value each time :)

Ketsuekiame 860 Master Poster Featured Poster

Erk, that error could be a multitude of things :(

Try adding this line above where you Open the workbook:
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");

(You might want to save your old culture settings to reset them after you finish working with the spreadsheet...)

YAE! (Yet Another Edit)
Seems Microsoft took retardation to a whole new level. Excel objects start at array index 1 and not 0...

Ketsuekiame 860 Master Poster Featured Poster

Did you make managed C++ code or unmanaged C++ code?

If you made unmanaged code, you will probably need to wrap that in managed code.

A little article on the MSDN about it

Otherwise, just linking it like you have should be enough...

Ketsuekiame 860 Master Poster Featured Poster

What line is it referring to?

EDIT:

Try access your spreadsheet like this instead:
ws.Cells[CurrentRow, 0] = row.Cells[accRefDgvColumnIndex]

Ketsuekiame 860 Master Poster Featured Poster

Yep! You access it by the column names that were in your database/dataset table.

It's the name of the column, not the header value :)

Ketsuekiame 860 Master Poster Featured Poster

No, if you continue on from your last update, just make the amendments I posted. The first three code lines of my last post, place above your foreach loop, adjust the foreach loop to reference the columns as in the posted code at the bottom of the post (I used yours as a template so you should be able to copy/paste)

I made the mistake of forgetting that what I use here, isn't exactly the same as what you will have. We have a toolkit here that extends ADO functionality. What I posted to you before, works here, but won't on your machine. So I had to go and find all the original ways of doing it. It just made it slightly messier.

Ketsuekiame 860 Master Poster Featured Poster

Me too; no need to apologise, not a fault of your service :)

Ketsuekiame 860 Master Poster Featured Poster

Right I see, it's not letting you call a cell index by name. Sorry, I'm not a regular user of straight up ADO, we have layers covering it to expand the natural functionality.

In that case you need to fetch the right column with that name.

Before you begin your data extraction, set three values that contain the column index of your datagridview column you're interested in.

This can be done like this:

Int32 accRefDgvColumnIndex = dataGridView1.Columns["AccountRef"].Index;
Int32 nameDgvColumnIndex = dataGridView1.Columns["Name"].Index;
Int32 postcodeDgvColumnIndex = dataGridView1.Columns["PostCode"].Index;

Admittedly this is getting a bit messy now. Might be wise to put all the column indexes into a Dictionary and key it on String.

So you would use:

foreach(DataGridViewRow row in dataGridView1.Rows)
{
    ws.Rows[CurrentRow].Column[0] = row.Cells[accRefDgvColumnIndex].Value;
Ketsuekiame 860 Master Poster Featured Poster

Problem was caused by the proxy I use at work rejecting the connection.

Ketsuekiame 860 Master Poster Featured Poster

Sorry I didn't give you actually working code, it was more pseudo code for logic.

The dgv.DataRows should just be dgv.Rows, this will give you a type of DataGridViewRow, which will have the property Cells, which you access via array to pull the value.

So more like;

foreach(DataGridViewRow row in datagridView1.Rows)
{
    Object column1Value = row.Cells["AccountRef"].Value;
    ...
}
Ketsuekiame 860 Master Poster Featured Poster

It becomes easier to conceptualise the outcome if you visualise the data segregation. Rather than seeing row numbers and column numbers, think about them in name format.

Your DGV already knows columns such as Name, Address, Account Reference etc.
You know where they will be going on your Excel report.

So in order for your code to know where they're going, setup some basic steps. This is hardcoding and therefore "bad" but in time you could always rip it out and make it configurable.

But let's say you output Account Ref, Name, Postcode;

public int AccRefColumn = 0; // Column A
public int NameColumn = 1; // Column B
public int PostCodeColumn = 2; // Column C

public int CurrentRow = 6; // Row 6

// semi-pseudo code incoming...
foreach(var dataRow in dgv.DataRows)
{
    excelSheet.Row[CurrentRow].Column[accRefColum] = dataRow["AccountRef"].Value;
    excelSheet.Row[CurrentRow].Column[NameColumn] = dataRow["Name"].Value;
    ...
    CurrentRow++;
}

excelSheet.Save();

Although it's good to strive for completely generic ways of doing things, sometimes, you just need to make it specific for the task. Without a lot more work outside of this particular function, I think this is the best approach.

Just heading off for lunch, I'll be back in about an hour if you need more assistance.

Ketsuekiame 860 Master Poster Featured Poster

Today is sunny with temperatures around 2C - 11:40am

Ketsuekiame 860 Master Poster Featured Poster

I think the easiest way to approach this is to give your application knowledge of what columns contain which data. Simply keep track of what row you're dealing with and increment through each iteration of your export.

Ketsuekiame 860 Master Poster Featured Poster

In my comment I said inheriting, but meant to type implementing. Sorry bout that!

Ketsuekiame 860 Master Poster Featured Poster

As for the mouse camera, it could be that the scaling you use for your modelview matrix and world matrix might be different, causing the mathematics to be well off when it calculates the camera position.

Ketsuekiame 860 Master Poster Featured Poster

Hiya, could you please post your Draw method, any classes that build up your vertex list and your main loop?

The slowdown sounds like it might be switching to software rendering mode for some reason, but that doesn't make sense really. Either that or he's using a different type of graphics card (between nvidia/amd) and what isn't a problem on yours, is on his. (Famously, ATi cards suffered a massive performance drop when you used a texture that wasn't a power of 2 in width and height which didn't occur on nVidia cards - this was back in 2004-ish)

Ketsuekiame 860 Master Poster Featured Poster

Yeah you could easily switch this to being Timers. Set them up to fire your download method every 15 seconds and set a second one to fire your label update every second. This will massively reduce your code complexity.

The other things I were talking about were more like mutexes. If you google for AutoResetEvent or ManualResetEvent and review the MSDN pages it should give you a basic understanding of how they work, however, I would not recommend this approach based on your requirement.

Ketsuekiame 860 Master Poster Featured Poster

Do you actually need to show every record all at once? I would implement paging. You can do this by setting the PageSize property on adoRS (your record set object) and then flip through the "pages".

Or, you can do this manually;

select col1, col2, col3, etc...
    from (
        select col1, col2, col3, ect..., ROW_NUMBER() OVER (order by orderColumn) as RowNum
        from yourTable
        ) as DerivedTable
where DerivedTable.RowNum between @startRow and @endRow

Just submit two row numbers to your query as parameters.

EDIT: Seems ADO has a hardcoded limit of 1000 records anyway so it may be wise to implement this if you have more...

Ketsuekiame 860 Master Poster Featured Poster

They say that The only thing to fear, is fear itself. Well, I say they've probably never been face to face with a bear!

Ketsuekiame 860 Master Poster Featured Poster

Used iPhone 4 and Galaxy S3; prefer the Galaxy S3 because it's better at what I want it to do. It's a more open architecture and I can poke and play with it to my heart's content. The music player is somewhat poor and has now been replaced with Spotify :P
The camera is much better than the 4, assuming this is down to software not the lens.

The iP4 is a good phone if you want something simple and does everything for you. It's a "nannying" phone. But if you want a music player, somewhere to store your photos and Facebook, the iPhone is probably what you want.

iOS vs Android - Android. For the simple reason that I don't have to pay to develop for it and I don't have to jump through 10,000 hoops to get software I've written onto the phone that I own.

tl;dr - Choose the right one for what you want. They both have pros and cons in different areas but are about the same overall.

Ketsuekiame 860 Master Poster Featured Poster

I did some Googling and found a couple of hits relating to Sage being slow with ADO connections.

Could it possibly be the network in between?

As a suggestion I would add timers to see if it's the data retrieval or the grid population that needs optimising. I'm guessing it's the retrieval personally.

EDIT: Also I noticed there is no cap on the number of records you retrieve. It may be worth saying "SELECT TOP 50" or "LIMIT 50" in the procedure to ensure that you aren't returning too large a dataset.

Ketsuekiame 860 Master Poster Featured Poster
Ketsuekiame 860 Master Poster Featured Poster

You're doing a stop run and pause run; are your threads triggered by some other process? If they are, you should look into events. With events, you can subscribe to them and they will be called as and when required. This means you won't need any complex thread control code.

If not (or you can't use events for marking reasons) then perhaps AutoReset or ManualReset events would be better.

The difference between the two is basically whether or not one closes the "gate" behind itself. You can then control these wait events independently. Whilst they are nonsignalled, any threads attempted to access them (with the WaitOne method) will block. You can then signal these events to allow a thread to pass through.

Ketsuekiame 860 Master Poster Featured Poster

Have you tried a more optimisitic locking strategy? (See line 20)

Ketsuekiame 860 Master Poster Featured Poster

Rather than trying to work with strings, place it into a data structure. It will be much easier to work with.

eg.

public class Weather
{
    public String Outlook
    {get;set;}

    public String Temperature
    {get;set;}

    public String Humidity
    {get;set;}

    public String Windy
    {get;set;}

    public Boolean PlayTennis
    {get;set;}
}

Then you can have a list of Weather and do lookup on that list.

Additionally, rather than using Strings you could use ENUM.

ddanbe commented: The way to go! +0
Ketsuekiame 860 Master Poster Featured Poster

England gets quite warm in the summer. But it comes and goes. One week it will be -5C, the next week it could be 15C the week after 20C then back down to 10C and so on. Extrememly random.

Our weather system relies on currents from elsewhere around the world and the gulf stream. If we don't get warm enough water coming up the stream, the temperature of the country plummets.

Ketsuekiame 860 Master Poster Featured Poster

I've been running Windows 8 for a while now and I have to say that for me, Metro is pointless. It seems the decision for Metro being the default "desktop" is because is massively improves start up time.

The next time you load Windows up, leave it a moment to do its normal "loading", then hit the desktop icon. Everything will start loading as your normal desktop would (from the point you clicked on it, not when your machine reached the metro page). By deferring this stage, they can claim exaggerated start-up times. So it seems normal Desktop mode may actually be an app that runs on Metro...

Performance wise Windows 8 is absolutely amazing. I've had people tell me it's slower than Windows 7 and show me numbers, which I'm inclined to believe are correct (millisconds out). However, the OS feels so quick and snappy you don't notice it. This is a vast improvement from XP and a good improvement from Windows 7.

Taking a look at the resources used in TaskManager, Windows 8 is extremely light-weight. This may be in part due to the model that Microsoft seems to want to take with their metro apps. It's possible that a close button isn't available because you're simply supposed to "Home" it, like on the iPhone.

For those that miss the original start menu, Pokki offer a free alternative that is Windows 8 styled. It's very sleek and quick.

Finally, I have had no problems with Windows 8 that …

Ketsuekiame 860 Master Poster Featured Poster

Same. At least 8 hours at work (usually around 10) then whatever time is left until 1am at home. I have activity days though where I will not go home but instead play Badminton or go Ice Skating or just visit friends.

As much as I love what I do, I like to unlock the chains every now and again ;)

Ketsuekiame 860 Master Poster Featured Poster

You can retrieve the UsedRange of the worksheet. That way you can determine if the worksheet has any data on it. If it's empty, you can delete the sheet.

Ketsuekiame 860 Master Poster Featured Poster

Yeah, you should be able to get the office library to remove the worksheets you don't need.

Once you load your spreadsheet, you should be able to select the worksheet (via an array) and call Delete() on it.

When you're done, save it again and you should be good to go :)

Ketsuekiame 860 Master Poster Featured Poster

What have you done so far? What specifically do you need help with?

Did you read any of the stickies or the posting rules?

Ketsuekiame 860 Master Poster Featured Poster

Seems odd that Reporting Services would add blank worksheets, wonder the reasoning behind it...

Do you have access to the MS Office library for .NET? That will be quite powerful for doing what you need.

Ketsuekiame 860 Master Poster Featured Poster

Thanks :)

I really want to help people help themselves. I like helping people and I like solving problems (partly why I decided to become a software engineer) but I'm learning that sometimes the best way to help isn't by doing it directly.

Ketsuekiame 860 Master Poster Featured Poster

Between 30-60 seconds the first time and half an hour the second time. Hit post and left for lunch, came back and it hadn't posted. Checked it hadn't posted by opening the thread in a new window.

Ketsuekiame 860 Master Poster Featured Poster

Before I start, I'm afraid I have to say I cannot reliably reproduce this, but it has happened to me twice today.

When replying to a post I press the button to confirm, the button disappears, replaced by the "Watch This Thread" button, however, the post is not submitted. The text box does not disappear, I can happily copy and paste my post into a new reply box.

The twice it has happened today, I have noticed that someone else has posted whilst I wrote my reply. Not sure if this is connected or not.

My User Agent string is: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11

PS. Just a little bug-bear of mine and not really a complaint, but when you press home on a wrapped line it goes to the beginning of the text not the beginning of the line.

Eg. Let's say this sentence is a long sentence and is wrapping on THIS word meaning everything beyond it is on another line and I want to go and change the word "word". If I hit the HOME key, it will go all the way back to "Let's" instead of "word".

Ketsuekiame 860 Master Poster Featured Poster

I have written some pretty horrific LINQ one liners in my time when I've been rushing.

Generally I newline curled bracers, nest everything and if a line gets too long, drop each argument to its own line, indented as appropriate to the current nested scope.

Ketsuekiame 860 Master Poster Featured Poster

Okay, there's a couple of ways you can do it.

Firstly, have a public field through which you can set the value.
Secondly, call a public method which sets the value explicitly.

First:

Form2 secondForm = new Form2();
secondForm.ConnectionString = textBox1.Text;
secondForm.Show();


....

In Form2:

OnLoad(object sender, EventArgs evt)
{
    textBox1.Text = ConnectionString;
}

Second:

Form2 secondForm = new Form2();
secondForm.SetConnectionString(textBox1.Text);
secondForm.Show();

....

Form2:

public void SetConnectionString(String connectionString)
{
    textBox1.Text = connectionString;
}

Alternatively, use the constructor. The best way would be to use a configuration object that you can call from your second form (Singleton accessor) so you needn't pass the data around.

Ketsuekiame 860 Master Poster Featured Poster

12:24 - It's cold. It's grey. Welcome to England :P

Ketsuekiame 860 Master Poster Featured Poster

I joined because I had a very specific query relating to something quite far "out there" in WCF, which an article on DaniWeb had already addressed. I decided to stick around for a while.

I mostly just answer questions in the C# forums and promote the twitter feed when I can. The community of here is much better and friendlier than places like SO. I find that SO is overrun by people who have blinkers on. It's their way or no way, which is why I believe DW is a much better place to be.

(Eventually I'll upload an avatar....)

Ketsuekiame 860 Master Poster Featured Poster

There is only one time I will turn to StackOverflow over DaniWeb and that is for XSLT problems because I know the forum is not the most active compared to the SO one and work issues generally need to be resolved quickly.

Argh! XSLT runs and hides

I've just inherited a project that heavily relies on it. So I had to do a massive amount of learning effectively overnight.

Now I have nightmares about it :P