Form1 Visible after Form2 Close: Child Form close, Parent Form Visible

July 6th, 2011 § 0 comments § permalink

Scenario. I want my application to have two forms. When I click a button on Form1, Form1 disappears, Form2 appears.

NOW.

When I close Form2, I want the original Form1 to become Visible again NOT instantiate a new Form1.
After a bit of playing around and googling, I found exactly what I was looking for at StackOverflow.

The answer on the question i-would-like-to-control-form1-from-form2 was exactly the solution I was looking for. Rather than repost it here, I encourage you to frolic over to stack and have a read!

Multiple Users Accessing a MySQL Database in C#

July 5th, 2011 § 1 comment § permalink

I’m working on a piece of software at the moment that will eventually require multiple users to access the database simultaneously. I’m a pretty basic coder, and I was wondering whether there was a way I could read/write to the database without using lock-in/lock-out controls. I was dreading have to do t.

I wanted the program to use a Microsoft Access 2007 Database, mostly because it would be very portable, rapid development that would be easy to backup when it went into operation. Performance isn’t so much an issue, seeing as there will 4 or 5 users maximum.

I had difficulty determining whether or not this could done. I don’t know why. I guess its obvious to most people.

The simple answer is it can be done. In both Microsoft Access and MySQL. Before I lept into development, I wanted to see how the database behaved in C#, so I thought I’d write a quick application to test whether or not I actually can write by multiple users.

(As it turns out, it can be done in Microsoft Access but I found it very problematic in my testing)

You’ll want an SQL database that is made to look like this:

CREATE TABLE helloworld(
id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
name VARCHAR(30));

And then compile this short c# program. Don’t forget to change the various settings that affect you.
You’ll need the MySQL .NET Connecter, and include a reference in your project.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
//the additional references you'll need
using System.Data;
using MySql.Data;
using MySql.Data.MySqlClient;
using System.Threading;
 
namespace mySQLTest
{
    ///
<summary> /// This program is written to prove that multiple threads or users can simulatenously access the MySQL data base and write. /// The MySQL connector handles the lockout or connection attempts automatically. /// </summary>
 
    class Program
    {
        static void Main(string[] args)
        {
            //declare two threads to act like users
            Thread thread1 = new Thread(new ThreadStart(DatabaseClass.doStuff));
            Thread thread2 = new Thread(new ThreadStart(DatabaseClass.doOtherStuff));
 
            //start the threads running
            thread1.Start();
            thread2.Start();
 
            //the current 'main' thread, should run in a loop until the other two have finished.
            while (thread1.ThreadState != ThreadState.Stopped &amp;&amp; thread2.ThreadState != ThreadState.Stopped)
            {
                Thread.Sleep(200);
            }
 
            //once the threads are finished, notify us through the console.
            Console.WriteLine("End");
            Console.ReadLine();
        }
    }
 
    static class DatabaseClass
    {
        ///
<summary> /// this function is quite well documented in the MySQL manual, the section that talks about .NET connectors. /// </summary>
 
        public static void doStuff()
        {
            string connStr = "server=192.168.3.11;user=root;database=world;port=3306;password=password;";
            MySqlConnection conn = new MySqlConnection(connStr);
            try
            {
                Console.WriteLine("Connecting to MySQL...");
                conn.Open();
 
                //i want to enter a thousand items
                int i = 0;
                do
                {
                    string sql = "INSERT INTO helloworld (name) VALUES ('user1')";
                    MySqlCommand cmd = new MySqlCommand(sql, conn);
                    cmd.ExecuteNonQuery();
                    i++;
                } while (i &lt; 1000);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            conn.Close();
            Console.WriteLine("Done.");
        }
 
        public static void doOtherStuff()
        {
            string connStr = "server=192.168.3.11;user=root;database=world;port=3306;password=password;";
            MySqlConnection conn = new MySqlConnection(connStr);
            try
            {
                Console.WriteLine("Connecting to MySQL...");
                conn.Open();
 
                int i = 0;
                do
                {
                    string sql = "INSERT INTO helloworld (name) VALUES ('user2')";
                    MySqlCommand cmd = new MySqlCommand(sql, conn);
                    cmd.ExecuteNonQuery();
                    i++;
                } while (i &lt; 1000);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            conn.Close();
            Console.WriteLine("Done.");
        }
    }
}

If you were to shoot into MySQL Console right now, and ran:

SELECT * FROM helloworld;

You’d be delighted (like I was), to find your two users have simultaneously written to the database.

Tree-rrific Tree Service

July 5th, 2011 § 0 comments § permalink

Working on another website at the moment. Tree-rrific Tree Service

The OLE DB provider “Microsoft.ACE.OLEDB.12.0″ has not been registered

June 22nd, 2011 § 0 comments § permalink

The OLE DB provider “Microsoft.ACE.OLEDB.12.0″ has not been registered.

Was the message I recieved from Visual Studio 2008 as I tried to use an Access database with my new application.

I protested quietly – knowing that the OLE DB providor WAS installed and WAS referenced in my project… I’d come across the problem before but couldn’t remember how I fixed it.
Getting Error “The OLE DB provider “Microsoft.ACE.OLEDB.12.0″ has not been registered”. when importing excel file. had the answer (a fair way down the page).

The Microsoft.ACE.OLEDB.12.0 is for x86 architecture – by default Visual Studio was compiling in x64.

Build > Configuration Manager > Platform > “New…” > x86

And it works!

Victorian Vegetation Management

June 18th, 2011 § 0 comments § permalink

I built a site for a company that specialises in all kinds of weed control and weed spraying.
Victorian Vegetation Management is based in the Yarra Valley and has a range of services rarely offered by other weed spraying groups.

 

EndNote Disappeared from Microsoft Office 2007

June 18th, 2011 § 0 comments § permalink

Came across an interesting problem – endnote removed itself from the toolbar in office 2007.
These is some incompatibility with the .dll and the new office, that emerges under certain conditions.
The most frustration part is that it isn’t clear how you restore it.

Office Button > Word Options > Add Ins > Manage : Disabled Items

This will tell you that something went wrong with EndNote – now all you need to do is click enable.
Restart Word, and your back again!

Can’t control record DV camera Adobe Premiere Pro

June 17th, 2011 § 0 comments § permalink

This may seem really dumb, but it will drive you up the wall if you’ve ever got caught in it.

Situation – you may be editing a HDV movie in Adobe Premiere Pro – but for some reason you’ve had to delve into the archive for some DV footage.
Annoyingly, you realise its still on tape. You blow the dust of the DV camcorder, plug it into the firewire – hear the satisfying device found sound.
You goto ‘Capture’ only to see that you cannot play or record the video.

I wasn’t even editing HDV when this happened, which in itself is a pretty big indicator of what the problem is, in fact I’d already dumped over 50 hours of DV footage!

Simple solution, somehow find the ‘Capture Format’ in the comparatively few options you have in the capture window, and change from HDV to DV.

Sherbrooke Tree Service

June 17th, 2011 § 0 comments § permalink

Sherbrooke Tree Service is a business trading under Chebter Pty Ltd that has been operating since 1976.

Graeme McMahon is owner, operator and main climber.

The services include

  • Tree Lopping
  • Tree Pruning
  • Tree Removal
  • Tree Felling
  • Storm Damage
  • Emergency Assistance

 

Lilydale Trailer Spares

June 17th, 2011 § 0 comments § permalink

Lilydale Trailer Spares was built for a company with the same name who are based in Lilydale.

They supply parts and services to Lilydale and the eastern suburbs of Melbourne.

Yarra Valley Trailer parts is probably a better way of looking at them.

They supply:

  • Trailer Parts
  • Trailer Repairs
  • Trailer Serving
  • Trailers for sale
  • Tandem Trailers
  • Tipping Trailers
  • Custom Trailers
  • Trailer Spares

If you need any of the above, get onto www.lilydaletrailerspares.com and give Terry a call!

Websites Built by Splents

June 17th, 2011 § 0 comments § permalink

Building websites is something that I’ve done on the side for a number of years. Recently, I’ve taken to building a lot of wordpress websites – I can produce them quickly and cheaply. Over time clients can slowly ad more to their sites and can change their marketing strategy without outlaying huge amounts of money early on. This is good.

One of the really important parts of SEO is link building – not bad links – valuable links.
I’ve held off blogging about the websites I’ve made, because generally my personal blog is contains tech related content that could potentially mess with my other sites results.
I no longer care. In fact, I’m interested to test out what exactly happens when I start building link trees. This is one reason.

The second reason is many of my clients have seen this website – whilst its casual approach to language, grammar and information is misleading – it does advertise well my interest in solving technical computing, surveillance, programming and radio problems. So, without further ado, I’ll begin sharing over time some of the websites I’ve built, am building, or have in the pipeline.