Sunday, January 24, 2010
Windows7 installation
Just installed Windows7, no hazzle and quick. Someone at MS actually to a good job.
Wednesday, January 20, 2010
.Net DataTable.Select bug
Be very careful how you write you FilterExpression using DataTable.Select(FilterExpression).
You add some columns to your DataTable without specifying what type they are it will be set to String as default. Later when you filter out data expecting integer datatype you get some corrupt stuff back. So don't forget ' ' around string parameters in your FilterExpression if you column are of String type.
The Net framework accept invalid filters and return crappy data back instead of saying that this FilterExpressing is crap, if your unlucky you will not find out until its too late.
Code example: (Same bad behavior occurs in C#)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim dt As New DataTable
dt.Columns.Add("ix1")
dt.Columns.Add("ix2")
dt.Columns.Add("ix3")
dt.Rows.Add(New Object() {1, 1, 8})
dt.Rows.Add(New Object() {3, 1, 8})
dt.Rows.Add(New Object() {3, 1, 8})
dt.Rows.Add(New Object() {3, 1, 8})
dt.Rows.Add(New Object() {3, 1, 8})
dt.Rows.Add(New Object() {3, 1, 8})
dt.Rows.Add(New Object() {5, 1, 8})
dt.Rows.Add(New Object() {5, 1, 8})
dt.Rows.Add(New Object() {13, 1, 8})
dt.Rows.Add(New Object() {13, 1, 8})
Dim x As Integer
Dim cnt As Integer
x = 1
cnt = dt.Select("ix1=" + x.ToString).Length
' THIS will return cnt=1
MsgBox("ix1=" + x.ToString + ", cnt= " + cnt.ToString)
x = 3
cnt = dt.Select("ix1=" + x.ToString).Length
' THIS will return cnt=5
MsgBox("ix1=" + x.ToString + ", cnt= " + cnt.ToString + ", this should be 5, wtf")
' Fix, column(0) is string instead of integer so filter will be for string
x = 3
cnt = dt.Select("ix1='" + x.ToString + "'").Length
' THIS will return cnt=5
MsgBox("ix1='" + x.ToString + "', cnt= " + cnt.ToString)
x = 13
cnt = dt.Select("ix1=" + x.ToString).Length
' THIS will return cnt=0 and not 2
MsgBox("ix1=" + x.ToString + ", cnt= " + cnt.ToString + ", this should be 2, wtf")
' Fix, column(0) is string instead of integer so filter will be for string
x = 13
cnt = dt.Select("ix1='" + x.ToString + "'").Length
' THIS will return cnt=2
MsgBox("ix1='" + x.ToString + "', cnt= " + cnt.ToString)
End Sub
You add some columns to your DataTable without specifying what type they are it will be set to String as default. Later when you filter out data expecting integer datatype you get some corrupt stuff back. So don't forget ' ' around string parameters in your FilterExpression if you column are of String type.
The Net framework accept invalid filters and return crappy data back instead of saying that this FilterExpressing is crap, if your unlucky you will not find out until its too late.
Code example: (Same bad behavior occurs in C#)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim dt As New DataTable
dt.Columns.Add("ix1")
dt.Columns.Add("ix2")
dt.Columns.Add("ix3")
dt.Rows.Add(New Object() {1, 1, 8})
dt.Rows.Add(New Object() {3, 1, 8})
dt.Rows.Add(New Object() {3, 1, 8})
dt.Rows.Add(New Object() {3, 1, 8})
dt.Rows.Add(New Object() {3, 1, 8})
dt.Rows.Add(New Object() {3, 1, 8})
dt.Rows.Add(New Object() {5, 1, 8})
dt.Rows.Add(New Object() {5, 1, 8})
dt.Rows.Add(New Object() {13, 1, 8})
dt.Rows.Add(New Object() {13, 1, 8})
Dim x As Integer
Dim cnt As Integer
x = 1
cnt = dt.Select("ix1=" + x.ToString).Length
' THIS will return cnt=1
MsgBox("ix1=" + x.ToString + ", cnt= " + cnt.ToString)
x = 3
cnt = dt.Select("ix1=" + x.ToString).Length
' THIS will return cnt=5
MsgBox("ix1=" + x.ToString + ", cnt= " + cnt.ToString + ", this should be 5, wtf")
' Fix, column(0) is string instead of integer so filter will be for string
x = 3
cnt = dt.Select("ix1='" + x.ToString + "'").Length
' THIS will return cnt=5
MsgBox("ix1='" + x.ToString + "', cnt= " + cnt.ToString)
x = 13
cnt = dt.Select("ix1=" + x.ToString).Length
' THIS will return cnt=0 and not 2
MsgBox("ix1=" + x.ToString + ", cnt= " + cnt.ToString + ", this should be 2, wtf")
' Fix, column(0) is string instead of integer so filter will be for string
x = 13
cnt = dt.Select("ix1='" + x.ToString + "'").Length
' THIS will return cnt=2
MsgBox("ix1='" + x.ToString + "', cnt= " + cnt.ToString)
End Sub
faulting module kernel32.dll, version 5.1.2600.3541, fault address 0x00012a6b.
I got following fault running my VB application from the IDE:
Faulting application MyApp.vshost.exe, version 9.0.21022.8, faulting module kernel32.dll, version 5.1.2600.3541, fault address 0x00012a6b.
It triggers on: Expanding a treeview or opening an old function that have been working for ages.
Stepping through the code doesn't really help, the fault triggers before opening the function.
When running the released exe, no fault is triggered, but running the debug version of the exe-file does. It turned out to be a common dll used by several objects that had different versions somehow.
So one day of scrathing my head finally solved.
Fix: Remove all /bin/debug and /bin/release the rebuild solution.
Faulting application MyApp.vshost.exe, version 9.0.21022.8, faulting module kernel32.dll, version 5.1.2600.3541, fault address 0x00012a6b.
It triggers on: Expanding a treeview or opening an old function that have been working for ages.
Stepping through the code doesn't really help, the fault triggers before opening the function.
When running the released exe, no fault is triggered, but running the debug version of the exe-file does. It turned out to be a common dll used by several objects that had different versions somehow.
So one day of scrathing my head finally solved.
Fix: Remove all /bin/debug and /bin/release the rebuild solution.
Monday, January 18, 2010
AT Commands
Playing around with my mobile phone dialing using Com-port over BlueTooth.
-Connect using HyperTerminal
- Select Comport, use default settings 2400,8,N,1
To make a call:
Type: ATDT ThePhoneNumber;
(Don't forget the ; at the end.)
To answer a Call:
Type: ATA
To hang up a call:
Type: ATH
You find lots of reference for 'AT commands' by searching on Google.
ref: http://developer.sonyericsson.com/getDocument.do?docId=65054
-Connect using HyperTerminal
- Select Comport, use default settings 2400,8,N,1
To make a call:
Type: ATDT ThePhoneNumber;
(Don't forget the ; at the end.)
To answer a Call:
Type: ATA
To hang up a call:
Type: ATH
You find lots of reference for 'AT commands' by searching on Google.
ref: http://developer.sonyericsson.com/getDocument.do?docId=65054
VB.Net BackgroundWorker
A BackgroundWorker runs an asyncron thread for you.
Private WithEvents backgroundWorker1 As New System.ComponentModel.BackgroundWorker
' Start the BackgroundWorker
Public Sub RunAbackgroundworker()
If Not backgroundWorker1.IsBusy Then
backgroundWorker1.RunWorkerAsync()
End If
End Sub
Dim i As Integer = 0
Private Sub backgroundWorker1_DoWork(ByVal sender As Object, ByVal e As _
System.ComponentModel.DoWorkEventArgs) Handles backgroundWorker1.DoWork
i = 0
Do
i += 1
If i > 100 Then
Exit Do
End If
System.Threading.Thread.Sleep(50)
Loop
End Sub
Private Sub backgroundWorker1_RunWorkerCompleted(ByVal sender As Object, _
ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles _
backgroundWorker1.RunWorkerCompleted
MsgBox("We are done now!")
End Sub
Private WithEvents backgroundWorker1 As New System.ComponentModel.BackgroundWorker
' Start the BackgroundWorker
Public Sub RunAbackgroundworker()
If Not backgroundWorker1.IsBusy Then
backgroundWorker1.RunWorkerAsync()
End If
End Sub
Dim i As Integer = 0
Private Sub backgroundWorker1_DoWork(ByVal sender As Object, ByVal e As _
System.ComponentModel.DoWorkEventArgs) Handles backgroundWorker1.DoWork
i = 0
Do
i += 1
If i > 100 Then
Exit Do
End If
System.Threading.Thread.Sleep(50)
Loop
End Sub
Private Sub backgroundWorker1_RunWorkerCompleted(ByVal sender As Object, _
ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles _
backgroundWorker1.RunWorkerCompleted
MsgBox("We are done now!")
End Sub
Subscribe to:
Posts (Atom)
MySQL to MariaDB
Here is a good description how to migrate to MariaDb MySQL to MariaDb Example of how to dump data from MySQL port=3307: mysqldump --user=ro...
-
When converting an VB2008 application to VB2010 I run into trouble regarding COM objects while compiling. you get errors like: Error 1...
-
In a module you have declared a Structure or Enum that you will use through out a project. Module Module1 Public Structure dummy ...
-
Apache2 crashes on Ubuntu Linux 22.04.5 after Zabbix was updated to 7.0.26 During a upgrade of my Ubuntu server there was a new package for ...