Thursday, April 15, 2010

.Net MySQL Connector Error

Apparently there is an error that can occur when a MySQL command tries to execute, but the execution takes longer than the default 'CommandTimeout' of 30 seconds.

To fix the problem, change to MySQLCommand.CommandTimeout to something more useful.

MySQL_Upgrade MySQL_Check fix for "column count of mysql.proc is wrong"

from command prompt: (remember to have NO space between '-p' and '[password]')

C:>mysql_check -u [user] -p[password] --repair --all-databases

This will repair your databases. This does not work on InnoDB.

C:>mysql_upgrade -u [user] -p[password] --all-databases

This will upgrade your databases.

This fixes the 'column count of mysql.proc is wrong' error when using MySQL Workbench on a databases that has been created with MySQL Server earlier than 5.2

Monday, April 5, 2010

Netstat

For networking information there are some handy 'Command Prompt' commands.

%> netstat

-a : listening and established ports
-an : all (I think)
-o: all owning processes with each connection

Tuesday, March 30, 2010

Monday, March 29, 2010

C# Event Handlers

I didn't know this but events can cause memory leaks.



This is a blog that shows how C# 4.0 events will not need to be locked. ( didn't know 3.0 events needed to be locked. )

Also, events can cause memory leaks if the Handler is not disposed of. ( myHander = null ).

Tuesday, March 23, 2010

SQLite to CSV in Python

To begin this mission, I know nothing about Python.

In 20 minutes, I have a sqlite database outputting data to a csv file.

WOW!

import sqlite3

conn = sqlite3.connect('C:/SQLite/db.sql')
curse = conn.cursor()

data = curse.execute('select * from Data where DATETIME([DateTime]) >= DATETIME("2010-03-20 05:00:00") AND DATETIME([DateTime]) <= DATETIME("2010-03-20 15:00:00");')

f = open('output.csv', 'w')

for row in data:
print >> f, row


------


7 lines of code. Awesome.

Wednesday, March 10, 2010

Debugging a Windows Service without installing

Well, first, to install using installutil [myapp.exe], you must put an environment variable in your system. -> InstallUtil.exe is in Microsoft.NET folder.

Visual Studio 2008 will not let you Debug a windows service. In the Project Properties, in the Debug tab, put [some command line argument...like /c for console]. This will send a command line argument to your application.

Surround the

ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new MainDataService()
};

ServiceBase.Run(ServicesToRun);

With an

if(commandLineArg == "/c")
{
[code above]
}

This will run your application in Visual Studio