Category Archives: .NET

.NET ComboBox Value Assignment notes

Recently i’ve encountered issue on assigning a value on ComboBox.   I’ve propagated the combobox value on the collection and I was assuming that everything will work as it is.

this.cboAvailableOnlyTallyTH.Text = this_particular_string; //this one is not working

this.cboAvailableOnlyTallyTH.SelectedText = this_particular_string; //this one is also not working

this.cboAvailableOnlyTallyTH.SelectedValue = this_particular_string; //this one is also not working

So frustrating that i’m really wondering why the value wont be assigned as i’m expecting. Later i realised that there are some extra spaces on the values which the string wont match.  I’ve finally fixed the issue by using the assignment statement .

this.cboAvailableOnlyTallyTH.SelectedIndex = this.cboAvailableOnlyTallyTH.FindString(this_particular_string;






Error code 9009 due to Missing ResGen.exe

I have this error :
When compiling a certain program, the error is showing :

The command “C:\Program Files (x86)\Microsoft Visual Studio 8\SDK\v2.0\Bin\ResGen.exe” “C:\Users\jojo\Desktop\project\Asterisk.NET.\Asterisk.NET.Test\fastagi-mapping.resx” fastagi-mapping.resources” exited with code 9009. Asterisk.NET.Test

I’m using MS Visual Studio 2008, and please note that the location of Resgen now is in : C:\Program Files\Microsoft SDKs\Windows\v6.0A\

So changing the “C:\Program Files (x86)\Microsoft Visual Studio 8\SDK\v2.0\Bin\ResGen.exe”

to “@”%ProgramFiles%\Microsoft SDKs\Windows\v6.0A\Bin\ResGen.exe”. fixes it.

Tamir.SharpSSH, C# and some linux shell command

I’ve found some interesting .NET class for accessing the linux server via SSH tunnel on this site – I’ve almost gave my task after experimenting the WinSCP active x plugin. I’ve decided to search again another code and found this library.
There are samples there on the source code but I’ve found the code ‘SSHExeTest.cs’ helpful for me.
Here is the revise code I have :

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Tamir.SharpSsh;
namespace WinSCP_Test
public partial class Form1 : Form
string _ipAddress = "";
string _username = "root"; // :) dont worry i'mjust playing on virtualbox I think its better not to use root in production
string _password = "xxxxxxx";
SshExec exec;

public Form1()
exec = new SshExec(_ipAddress, _username);
exec.Password = _password;
private bool isScriptRunning()

string command = "ps ax | grep -e '[t]'";
string output = exec.RunCommand(command);
string[] output_arr = output.Trim().Split(' ');
return output != "";
private void runScript()

string command = "/usr/bin/python /root/ > /dev/null &";

private void killScript()
string command = "ps ax | grep -e '[t]'";

string output = exec.RunCommand(command);
string[] output_arr = output.Trim().Split(' ');
output = exec.RunCommand("kill -9 " + output_arr[0]);


private void button1_Click(object sender, EventArgs e)
if (this.isScriptRunning())
if (MessageBox.Show("Script is running kill it?", "", MessageBoxButtons.YesNo) == DialogResult.Yes)
if (MessageBox.Show("Script is is not running,run it?", "", MessageBoxButtons.YesNo) == DialogResult.Yes)


private void button2_Click(object sender, EventArgs e)

private void Form1_FormClosing(object sender, FormClosingEventArgs e)

Overcoming RowFilter and Select Limitation

In ADO.NET, you can use the DataView.RowFilter property and the DataTable.Select method to filter a subset of records. However, the expressions that you can use have limitations. This article demonstrates three techniques to work around the limitations of the filter expressions.

‘DataTable1 is an existing DataTable object.
DataTable1.Columns.Add(“Flag”, GetType(Boolean))
DataTable1.Columns(“Flag”).ColumnMapping = MappingType.Hidden
Dim dr As DataRow
For Each dr In DataTable1.Rows
‘ If the criteria are satisfied Then
dr(“Flag”) = True
‘ End If
Dim dv As New DataView(DataTable1, “Flag = True”, “”, DataViewRowState.CurrentRows)
DataGrid1.DataSource = dv

DOS Reports using Foxpro 2.6

The code below i believe is useful in my program.

if (System.IO.File.Exists("d:\pepesfile\rd-png\fpd26\foxprox.exe" ))
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.WorkingDirectory = "d:\pepesfile\rd-png\hrdpayroll\";
proc.StartInfo.FileName = "d:\pepesfile\rd-png\fpd26\foxprox.exe";
proc.StartInfo.Arguments = "";

Disabling the Cell in Datagrid

Though I’ve already created a program for this in the QCS of Purchasing, I opt to review the code which I’ve written before…In the Production progs, a feature was request by my colleague and I’ve program this

Public Class DatagridCellxCellEnable
Inherits DataGridTextBoxColumn
Private _col As Integer
Public Sub New(ByVal column As Integer)
_col = column
End Sub
Public Delegate Sub EnableCellEventHandler(ByVal sender As Object, ByVal e As DataGridEnableEventArgs)
Public Event CheckCellEnabled As EnableCellEventHandler
Protected Overloads Overrides Sub Edit(ByVal source As System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer, ByVal bounds As System.Drawing.Rectangle, ByVal [readOnly] As Boolean, ByVal instantText As String, ByVal cellIsVisible As Boolean)
Dim enabled As Boolean
enabled = True
Dim e As DataGridEnableEventArgs
e = New DataGridEnableEventArgs(rowNum, _col, enabled)
RaiseEvent CheckCellEnabled(Me, e)
If e.EnableValue Then
MyBase.Edit(source, rowNum, bounds, [readOnly], instantText, cellIsVisible)
End If
End Sub
End Class

In my code i’ve included this

Dim numCols As Integer = Me.dtProdVolume.Columns.Count
Do While (i < numCols) Dim aColumnTextColumn As DatagridCellxCellEnable aColumnTextColumn = New DatagridCellxCellEnable(i) aColumnTextColumn.MappingName = Me.dtProdVolume.Columns(i).ColumnName AddHandler aColumnTextColumn.CheckCellEnabled, _ New DatagridCellxCellEnable.EnableCellEventHandler(AddressOf SetEnableValues) tableStyle.GridColumnStyles.Add(aColumnTextColumn) i = i + 1 Loop

an example c# code for this is available here

More on SQLite Backend Discussion

I found some odd instruction in the SQLite 3.0 version.
The following works properly in PostgreSQL

SELECT * FROM totp WHERE wk BETWEEN DATE '1980-05-20'
AND DATE '1980-05-26'

and its equivalent in MS SQL is :

SELECT * FROM totp WHERE wk BETWEEN '1980-05-20'
AND '1980-05-26'

while on the SQLite its equivalent of this is :

SELECT * FROM totp WHERE wk BETWEEN date('1980-05-20')
AND date('1980-05-26')

Notes on SQLite Data Provider

I’m using Finisar namespace as my data provider for SQLite Database in the Timecard program. The only problem I have is that unlike the other database managers like Postgresql, Mysql and MS SQL, it doesn’t have an inherent date computation program.

If my solution wont work, I will then resort to and row by row I’ll compute the interval of each date on that data.

This is the result of the new code. More complex than the normal coding in SQL Server, but I guess it solves my problem.
sqlite> select (strftime('%s',pmend)-strftime('%s',pmstart))/3600 as t1,pmstart,pmend from vwdtsdetail where dtsdetailid= 20;
5.5|2006-04-19 13:00:00|2006-04-19 18:30:00

Another thing that i observed in sqlite is that the function strftime wont work if the datetime format doesn’t appear like this : yyyy-MM-dd HH:mm:ss
and the date format is : yyyy-MM-dd