Monday, March 28, 2011

Workshop Aplication Using VB.Net and MySQL (Part 1)

First step to create project Workshop Aplication Using VB.Net and MySQL is create a database and tables in MySQL with design like below:

Database Name : WORKSHOP
Tables :
1. Customer
  
Fields Type SizeNote
customer_id
customer_name
sex
birthday
varchar
varchar
varchar
date
10
25
10
default
Pimary




2. Goods_Service
Fields Type SizeNote
item_code
item_name
price
varchar
varchar
float
10
25
default
Pimary



3. Service_header

Fields Type SizeNote
service_number
date
customer_id
total
varchar
date
varchar
float
10
default
10
default
Pimary




4. Service_detail

Fields Type SizeNote
id
service_number
item_code
price
qty
sub_total
integer
varchar
varchar
float
float
float
default
10
10
default
default
default
Pimary, Auto









Sunday, March 27, 2011

Connection VB.Net With MySQL Using Mysql ODBC Connector

To create Connection VB.Net With MySQL Using Mysql ODBC Connector follow this step below :
  1. Download mysql-connector-odbc-5.1.5 here
  2. Create a module in your project and insert this code below :

Module KoneksiData
Public KONEKSI As String
Public xSql As String
Public STATUS_Input As Boolean = False
Public CONN_odbc As New Odbc.OdbcConnection
Public CMD_odbc As New Odbc.OdbcCommand
Public DTReader_odbc As Odbc.OdbcDataReader
Public DTReader2_odbc As Odbc.OdbcDataReader
Public DTAdapter_odbc As New Odbc.OdbcDataAdapter
Public DTtable_odbc As New DataTable
Public BARIS_Edit As Integer

Dim ser, db, user, pass As String

Sub OPEN_MYSQL_WITH_ODBC()
ser = "127.0.0.1"
db = "yourdb"
user = "username"
pass = "password"
Try
KONEKSI = "DRIVER={MySQL ODBC 5.1 Driver};SERVER=" & ser & ";DATABASE=" & db & ";UID=" & user & ";PWD=" & pass & ";port=3306;OPTION=2105"
CONN_odbc = New Odbc.OdbcConnection(KONEKSI)
CONN_odbc.Open()

Catch Salah As Exception
MessageBox.Show(Salah.Message, "Error Koneksi", MessageBoxButtons.OK, MessageBoxIcon.Error)
End
End Try

End Sub

End Module

3. Call your connection in your form with this code "Call OPEN_MYSQL_WITH_ODBC() "

Thursday, March 24, 2011

Create VB.Net Connection With SQL Server (Part 2)

Create VB.Net Connection With SQL Server using ODBC. After creating database in SQL Server see Create VB.Net Connection With SQL Server (Part 1), next step is creating ODBC in control panel :
Previously we have made through the CONTROL PANEL CONNECTIONS - Administration Tools - ODBC, which serves to make the connection to the Database to be used which will be used for LINK TO APLICATION and REPORT.
By using ODBC, then all our database connections can easily be provided NAME / DRIVER DATABASE they have been listing in ODBC.

 STEP TO CREATE ODBC :
1. Open Control Panel - Administrative Tools - Choose ODBC
2. In ODBC Data Source Administrator choose User DSN Tab
3. Click Add
4. In Create New Data Source Dialog choose "SQL Server"
5. For this connection use ODBC_WORKSHOP  as name of connection, Server = Local and choose WORKSHOP for database.