----------
Custom Search

Monday, February 23, 2015

Connecting C# Visual Studio to MySQL Database

1. Download and install mysql .net connector http://dev.mysql.com/downloads/connector/net/
2. Add mysql .net on your reference.
    > at Visual Studio. Solution Explorer. Right Click Reference >> Add Reference
    > Search MySQL. Choose MySQL.Data
3. On your code:
    Sample:

    MySqlConnection myConnection = new MySqlConnection();
    MySqlCommand myCommand = new MySqlCommand();

    private string cs = "user id=root;password=;server='localhost';database=water_db; Convert Zero                                         Datetime=True;";
   
    myConnection.ConnectionString = cs;
    myConnection.Open();


// Smaple for Query - Save Data to Data Table
        DataTable tblResult = new DataTable();
        MySqlDataAdapter da = new MySqlDataAdapter("Select * from table", myConnection);
        da.Fill(tblResult);

// Sample for NonQuery
    myCommand.CommandText = "Insert Into etc.etc.etc.";
    myCommand.Connection = myConnection;
    myCommand.ExecuteNonQuery();

Simple?

Saturday, May 19, 2012

STOP UNSUBSCRIBE GLOBE 2332

How to stop Ringback, Jokes, Qoute from Globe 2332?

TEXT: STOP ALL
TO: 2332

This cost me a lot of load.

Thursday, February 16, 2012

Hang/Freeze on Windows CE .NET

I develop a System which prints statement from Mobile Device to a Bluetooth Printer.
Device - Windows CE - CipherLab 8600
Printer - Apex 2 - Bluetooth Communication
Developmet Tool - VB.NET Mobile

Problem- When I print - occasionally System / Unit Hang/Freeze.

After Days of research and trials.
This is my solution Solution.
- Change my Framework to 3.5
- Use Thread in Printing
Why? - Because in Mobile Device the application run in threads not in process.
The Application Freeze/Hang because there are to much process in the thread.
Maybe the unit can't handle it.
How?
- The problem in thread is that in cannot save / include your variables.
- So what I did is I save my printout into a text file then open it in the new thread
Example Code:

Public Sub print()
createtxt()

Dim t As System.Threading.Thread = New System.Threading.Thread(AddressOf printbilltr) ' Create New Thread
t.Start() ' Start Thread
End Sub

Public Sub createtxt()
Dim owrite As System.IO.StreamWriter
Dim vprint

owrite = System.IO.File.CreateText("\Diskonchip\4print.txt")

vprint = vprint & "STATMENT OF ACCOUNT" & vbCrLf
vprint = vprint & "NAME " & p_name & vbCrLf
vprint = vprint & "ADDRESS " & p_addr & vbCrLf

owrite.Write(vprint)
owrite.Close()
End Sub

Public Sub printbilltr()
Dim SePo As New IO.Ports.SerialPort ' Create Port
Dim oread As System.IO.StreamReader
Dim ychar

Try
oread = System.IO.File.OpenText("\Diskonchip\4print.txt")

' Set Port Setting
With SePo
.PortName = "COM6"
.BaudRate = 115200
.DataBits = 8
.Parity = IO.Ports.Parity.None
.StopBits = IO.Ports.StopBits.Two
.Handshake = IO.Ports.Handshake.None
.WriteTimeout = 5000
.WriteBufferSize = 10000
End With

While Not oread.EndOfStream()
ychar = oread.ReadLine()

If Not SePo.IsOpen Then
SePo.Open()
End If
SePo.Write(ychar & vbCrLf)
System.Threading.Thread.Sleep(5) ' Little Delay
End While
oread.Close()
Catch ex As Exception
Dim aaa
aaa = MsgBox("Printer Error" & vbCrLf & "- See Printer Status" & vbCrLf & "- Check Bluetooth is On" & vbCrLf & "- ReseT UniT if Needed")
End Try
End Sub

Hope This Helps..

Wednesday, December 28, 2011

SCADA Communication

The SCADA system for factories and utilities are quite different.
Factories commonly use LAN as their communication while utilities use WAN due to equipment/plants are located very remote.

In our SCADA system at BENECO we use 2 redundant WAN communication. We use Fiber Optic line w/ DLink media converter and combination of Dlink and Cisco Switches. and Engenius(802.llg) for our wireless Communication for our backup.

Based from the experience this is the comparison we observed between the two communication type.


Fiber Optic

WireLess (802.11g)

Speed is Faster( Greater than 1GBps)

Speed is Slower( Less than 64Mbs)

Installation of Fiber/Line - Physically : Underground / Overhead

No Need for Communication Wire/Line but must be Line of Sight

More Expensive (Termination/Fusion)

Less Expensive (Can be configured via internal web based application)

More Prone to damages - Cut Line/Wire (Fusion is Expensive)

Replace and Install (Just Copy the Save configuration)


Each have there advantages and disadvantages. So acquiring communication is based on your specific design.

Tuesday, February 22, 2011

Free Domain and Host

I just created a sample website using free domain name and web host.

domain name : makoylabz.co.cc

web host (nameserver) : n1.0fees.net & n2.0fees.net

I can test my sample webpage using this free domain and host for my project. I will only purchase the premium account of 0fees.net if my site is working properly then I will purchase for my domain name from other sites.

Sometimes a free webhost is good (testing purposes only). But you must not always rely on free webhost/domain, because you are not guaranteed if your webpage is lost or deleted..

Cannot Connect to Wifi – User Credentials – Vista

I’m at an office and ask for their wifi password. I notice that there Wifi/router (Linksys Cisco) is WEP encrypted so not really secure. But the problem arise when my vista OS is asking for user Credentials (username , password , login domain ). so what I did was go to

1. Network and Sharing Center

2. Manage Wireless Network

3. Add

4. Manually create a network profile

5. Fill up Network Name. to see network name just view available network and you see the network name (I’ve been stuck here for 2 days, just for an error that i miss cased one letter on my network name. so be sure to it that network name are exact. CASE sensitive)

6. Security Type: WEP – you can also see the security type at view available network

7: Security Key: ****** note case sensitive again – Check the box if you want to display the security key you typed.

8. NExt

If done correctly.. you must be connected automatically

Ubuntu Random Freeze/Hang

I’m new in Linux and I found this following solution.

after I install ubuntu linux 10.04/10.10 the systems randomly hang after a few seconds or minutes. Computer hard reset is the only solution. But if you use the safemode mode the system will run normally and will not freeze/hang.

Solution:

The problem may be your video adapter (intel/nvidia)

1. Run in safemode.

2. Remove / Un-install your video driver. Go to Systems>Administration>Synaptic Package Manager (Enter you password)

3. Search for xserver-xorg-video-intel (mostly this problem occur on intel computers – hahahahaha)

4. Mark for Removal then Apply

5. Restart Computer and Log-in normally.

Hope this solves your problem….