Monday, October 8, 2007

Thai language on MySQL with C# .NET

If you want to INSERT, UPDATE, SELECT in thai language on ODBC connection with MySQL, you should set CHAR SET = utf8 or any more (on MySQL). But you must set Character Set = tif620 (on Connector/ODBC of MySQL). After that you should set Initial Statement = SET NAMES 'tis620'. According, you can execute any command with thai language.

Sunday, October 7, 2007

C#.NET connect with MySQL

1. Download and install the latest .NET Framework SDK.
2. Install Microsoft Data Access Components (MDAC) 2.6 or later. MDAC 2.8 is the latest and is recommended.
3. Install the ODBC.NET Provider. Note that this step is only necessary if you are building applications using .NET 1.0. The ODBC provider comes standard with .NET 1.1. S;q319243.
4. Install MySQL Server. For more information on how to install and setup the MySQL Server, refer to the Installation chapter of the MySQL Reference Manual.
5. Now install MySQL ODBC Driver-MyODBC 3.51; and for installation instructions, refer to the Installation section of the Connector/ODBC documentation.
6. Setup an MyODBC DSN to be used for connecting to MySQL by following the instructions in the "DSN on Windows" section of the Connector/ODBC documentation.
http://dev.mysql.com/tech-resources/articles/dotnet/

For example source code to connect MySQL on C#
using System.Data.Odbc;

OdbcConnection MyConnection = new OdbcConnection("DSN=MyDNSName");
MyConnection.Open();

// If you want to customize your new DNS use this example code
string MyConString = "DRIVER={MySQL ODBC 3.51 Driver};" + "SERVER=localhost;" + "DATABASE=test;" + "UID=venu;" + "PASSWORD=venu;" + "OPTION=3";
OdbcConnection MyConnection = new OdbcConnection(MyConString);
MyConnection.Open();

link http://dev.mysql.com/tech-resources/articles/dotnet/
simple example query link
http://www.easysoft.com/developer/languages/csharp/ado-net-odbc.html#example

Wednesday, September 12, 2007

Getting Start Struts2.0 vs NetBeans

Make WebApplication on Netbeans with struts2.0 follow this link It will show the tutorial
http://essentialtechjunks.blogspot.com/2007/01/first-struts-20-application-with.html

Wednesday, September 5, 2007

Using TemplateFields in the GridView Control

n Visual Studio 2005(ASP, C#), I build my website and I want to add FormView to GridView, I can find the answer in http://msdn2.microsoft.com/en-us/library/bb288032.aspx.
If you understand in this tutorial you can add every component to GridView and bind data to its.

Thursday, August 30, 2007

Text to Postscript in JAVA

Refference from http://www.java2s.com/Code/Java/2D-Graphics-GUI/TexttoPostscript.htm
this is an example code that write in JAVA to canvert from string to PostScript format.

Monday, August 27, 2007

Wednesday, August 22, 2007

Virtual hosting with IIS on Windows Server versions

The method to create virtual host for IIS follows link below
http://www.simpledns.com/kb.aspx?kbid=1149

Install ASP.NET to IIS

After you install IIS and .NET Framwork
you must do this
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>aspnet_regiis -i
After that you can run aspx page on your server.

Tuesday, August 21, 2007

Virtual Host for Apache

file httpd.conf

NameVirtualHost 127.0.0.1

DocumentRoot C:/AppServ/www
ServerName test1.com

allow from all
Options +Indexes



site name is test1.com

edit file host in
C:\WINDOWS\system32\drivers\etc\
add your site name such as
127.0.0.1 test1.com

Wednesday, August 1, 2007

JAVA Printer vs Customize Paper Size

How to printing in my paper size?
If you want to print to your custom paper size, you can custom in your java code(Paper Class or findMediaSize() method), but if the custom size does not in the standard paper sizes, Printer API will select the nearly paper size from standard sets(height must more than width forever).
According above, it can't completely when your paper isn't in standard size sets. You can do this to add your paper size to standard sets
in this case my OS is Windows XP
goto -> Printers and Faxes -> File -> Server Properties (in this dialog you can add your paper)

After you do that, the Printer API will see your paper in standard sets but paper height must more than width forever.

Wednesday, July 25, 2007

Use TableCellRenderer in swing(java)

follow code example.
public class InfoCheckStockErrorTableCellRenderer extends JCheckBox implements TableCellRenderer{
/** Creates a new instance of InfoCheckStockErrorTableCelRenderer */
public InfoCheckStockErrorTableCellRenderer() {
super();
setHorizontalAlignment(this.CENTER);
}

public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
InfoCheckStockErrorTableModel model = (InfoCheckStockErrorTableModel) table.getModel();
setEnabled(!model.getIsAjustFromDB(row));
if (isSelected) {
setForeground(table.getSelectionForeground());
super.setBackground(table.getSelectionBackground());
} else {
setForeground(table.getForeground());
setBackground(table.getBackground());
}
boolean isAjust = ((Boolean) value).booleanValue();
setSelected(isAjust);
return this;
}
}

JAVA singleton class

Code below, you can make singlton class(has only one object).
public class AppFunction {
private static AppFunction af;
private AppFunction() {
}
public static AppFunction getInstance(){
if(af!=null){
return af;
} else{
af = new AppFunction();
return af;
}
}
}

Tuesday, July 24, 2007

JAVA Printing vs Font size

You can get the height of line from font. Example according code below.
public int print(Graphics g, PageFormat pf, int pageIndex){
Font font = new Font("Serif", Font.PLAIN, 14);
FontMetrics metrics = g.getFontMetrics(font);
int lineHeight = metrics.getHeight();
}

Dotmetric Printer vs java Programing

The paper must have height more than width.
The printer can set the position of paper in and paper out(for cutting paper) in continue paper.

Thai language with MySQL

db.connection("jdbc:mysql://"+dbIp+"/"+dbName+"?user=root&password=1234&useUnicode=true&characterEncoding=UTF-8");
Because of in java code (Netbeans) use UTF-8 Encoding, so I need to connect with UTF-8 encoding.
After this point I always will write or read Thai language from DB.