Programmers

They could change the world,., You too,..

Accuracy

A good application needs accurate datas,..

Controlling

A good application needs ability to control business flow.,,

Visual Basic 6.0 Form

Forms for entry the datas,..

Reports

The goal of a application show the reports of business datas,..

Contact Form

Name

Email *

Message *

Showing posts with label Modul. Show all posts
Showing posts with label Modul. Show all posts

Monday, September 23, 2013

Create connection test tool using VB 6.0

Now, we will create a tool to test a connection to the database. Here the steps,..

Step 1
Create New Project, and create new form like picture below,..


Step 2
Don't forget add Reference by click on Project Menu-->Reference





Step 3
Add this script in the Command Button control...




Saturday, September 21, 2013

Create a database connection script in a VB 6.0 Modul

Now, we will create a database connection script in a VB 6.0 Modul

Step 1
Click Menu Project--->Add Modul

Step 2
Add this scrip to the Module
|-----
Option Explicit
Public oConn As ADODB.Connection
Public rsXData As ADODB.Recordset
Public xSQL As String

Public Sub opendb()
  Set oConn = New ADODB.Connection
  Set rsXData = New ADODB.Recordset
  oConn.CursorLocation = adUseClient
  oConn.Open "Provider=Microsoft.ACE.OLEDB.12.0;" & _
                       "Data Source=" & App.Path & "\data.accdb;Jet OLEDB:Database Password=0rch1d;"
End Sub|-----



How  to create a Visual Basic 6.0 Modul? Here it is,...
 

Here references that you could to learn.

Friday, September 20, 2013

Modul in VB 6

Code in Visual Basic is stored in the form of modules. The three kind of modules are Form Modules, Standard Modules and Class Modules. A simple application may contain a single Form, and the code resides in that Form module itself. As the application grows, additional Forms are added and there may be a common code to be executed in several Forms. To avoid the duplication of code, a separate module containing a procedure is created that implements the common code. This is a standard Module.
Class module (.CLS filename extension) are the foundation of the object oriented programming in Visual Basic. New objects can be created by writing code in class modules. Each module can contain:

Declarations : May include constant, type, variable and DLL procedure declarations.

Procedures : A sub function, or property procedure that contain pieces of code that can be executed as a unit.
These are the rules to follow when naming elements in VB - variables, constants, controls, procedures, and so on:
  • A name must begin with a letter.
  • May be as much as 255 characters long (but don't forget that somebody has to type the stuff!).
  • Must not contain a space or an embedded period or type-declaration characters used to specify a data type; these are ! # % $ & @
  • Must not be a reserved word (that is part of the code, like Option, for example)
  • The dash, although legal, should be avoided because it may be confused with the minus sign. Instead of First-name use First_name or FirstName.


Making a connection to SQL Server 2000-2008 VB6

Basically any commands for manipulating databases perform well, add or update definitely needs an operation connection, and therefore do not need to create a script that repeatedly the connection needs to be made in connection script in the module file. And if necessary just call use the command "Call  <procedurename>"
Step 1
Open a new project, select the Enterprise.
Click the Project menu, click Add Module, click OK
Enter the following code in the module, then Save, ..

---
Option Explicit
Public conn As ADODB.Connection
Public recset As ADODB.Recordset

Public Sub opendb()
  Set oConn = New ADODB.Connection
  Set recset = New ADODB.Recordset
  oConn.CursorLocation = adUseClient
  oConn.Open "Provider=SQLOLEDB.1;Password=b217an;User ID=sa;Initial Catalog=Xserver;Data     Source=local"
End Sub
---

Step 2
They will just call the procedure in the form with the Call command, if the sample is placed at the time the form was called / load:

Private Sub Form1_Load()
 Call opendb
 Set recset = New ADODB.recordset

 recset.Open ("select * from data_pegawai"), oConn
 DataGrid1.Data Source = recset

 '----
in order to save memory resources and then close again  recset.Close
 Set recset = Nothing
 oConn.Close
End Sub


 
 

Wednesday, September 18, 2013

Data Base Class ADODB Command Recordset vb6



Data Base Class ADODB Command Recordset VB6 ADO FILE HANDLING OPEN

Introduction
This is Basically a Database class. In this project we connect to sql server 2000. We insert, update, delete and select queries. And also fill the grid with out using any data control. In this project i also use file handling.
Using the Code
First create the private member of the class. The three member of the class.

Option Explicit
Public oConn As ADODB.Connection
Public rsXData As ADODB.Recordset

1.  ADODB.connection This is for initialize the ADODB connection. This object use to connect the data base. 
2.  ADODB.Recordset 
This is for initialize the Recordset. This object for multiple purpose, but generally this object for collecting  the rows and fields. 

Public Sub opendb()
 On Error GoTo err1:
        Dim txtdbfile As String
        Dim txtpassword As String
        Dim Filename As String
        Filename = "" & App.Path & "\Label.txt"
        Open (Filename) For Input As #1
        Line Input #1, txtdbfile
        Line Input #1, txtpassword
 Close #1
        Set oConn = New ADODB.Connection
        Set rsXData = New ADODB.Recordset
        oConn.CursorLocation = adUseClient
        oConn.Open "Provider=Microsoft.ACE.OLEDB.12.0;" & _
                   "Data Source=" & App.Path & "" & txtdbfile & "" & _
                   ";Jet OLEDB:Database Password=" & txtpassword & ";"
err1:
Close #1
       Exit Sub
End Sub
 

Connection to SQL Server 2012

.NET Framework Data Provider for SQL Server

   | Server=myServerAddress;Database=myDataBase;User Id=myUsername;

   | Password=myPassword;

SQL Server Native Client 11.0 OLE DB Provider

   | Provider=SQLNCLI11;Server=myServerAddress;Database=myDataBase;Uid=myUsername;

   | Pwd=myPassword;

If  you using SQL Server 2012 Express, don't miss the server name syntax Servername\SQLEXPRESS where you substitute Servername with the name of the computer where the SQL Server 2012 Express installation resides.

SQL Server Native Client 10.0 OLE DB Provider

   | Provider=SQLNCLI10;Server=myServerAddress;Database=myDataBase;Uid=myUsername;

   | Pwd=myPassword;

SQL Native Client 9.0 OLE DB provider

   | Provider=SQLNCLI;Server=myServerAddress;Database=myDataBase;Uid=myUsername;

   | Pwd=myPassword;

Microsoft OLE DB Provider for SQL Server

   | Provider=sqloledb;Data Source=myServerAddress;Initial Catalog=myDataBase;

   | User Id=myUsername;Password=myPassword;

SQL Server Native Client 11.0 ODBC Driver

   | Driver={SQL Server Native Client 11.0};Server=myServerAddress;

   | Database=myDataBase;Uid=myUsername;Pwd=myPassword;

SQL Server Native Client 10.0 ODBC Driver

   | Driver={SQL Server Native Client 10.0};Server=myServerAddress;

   | Database=myDataBase;Uid=myUsername;Pwd=myPassword;

SQL Native Client 9.0 ODBC Driver

   | Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase;

   | Uid=myUsername;Pwd=myPassword;

Microsoft SQL Server ODBC Driver

   | Driver={SQL Server};Server=myServerAddress;Database=myDataBase;Uid=myUsername;

   | Pwd=myPassword;

Connection to My SQL

MySQL Connector/Net

Standard
    | Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
    | MySQL

Specifying TCP port
    | Server=myServerAddress;Port=1234;Database=myDataBase;Uid=myUsername;
    | Pwd=myPassword;

MySQLDriverCS

    | Location=myServerAddress;Data Source=myDataBase;User ID=myUsername;
    | Password=myPassword;Port=3306;Extended Properties="""";

SevenObjects MySqlClient

    | Host=myServerAddress;UserName=myUsername;Password=myPassword;Database=myDataBase;

dotConnect for MySQL (former MyDirect.NET and Core Labs MySQLDirect.NET)

    | User ID=root;Password=myPassword;Host=localhost;Port=3306;Database=myDataBase;
    | Direct=true;Protocol=TCP;Compress=false;Pooling=true;Min Pool Size=0;
    | Max Pool Size=100;Connection Lifetime=0;

MySQL OLEDB

    | Provider=MySQLProv;Data Source=mydb;User Id=myUsername;Password=myPassword;

.NET Framework Data Provider for OLE DB

    | Provider=any oledb provider's name;OledbKey1=someValue;OledbKey2=someValue;

MySQL Connector/ODBC 5.1

Local database

    | Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=myDataBase;
    | User=myUsername;Password=myPassword;Option=3;

On 64 bit machine
It seems we need to point on MSDASQL for the (32 bit) ODBC driver to work on 64 bit machines.

    | Provider=MSDASQL;Driver={MySQL ODBC 5.1 Driver};Server=localhost;
    | Database=myDataBase;User=myUsername;Password=myPassword;Option=3;

64 bit version of the driver
Note the "w" in the driver name.

    | Driver={MySQL ODBC 5.2w Driver};Server=localhost;Database=myDataBase;
    | User=myUsername;Password=myPassword;Option=3;

Remote database

    | Driver={MySQL ODBC 5.1 Driver};Server=myServerAddress;Database=myDataBase;
    | User=myUsername;Password=myPassword;Option=3;
  
Specifying TCP/IP port

    | Driver={MySQL ODBC 5.1 Driver};Server=myServerAddress;Port=3306;
    | Database=myDataBase;User=myUsername;Password=myPassword;Option=3;

MySQL Connector/ODBC 3.51

Local database

    | Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=myDataBase;
    | User=myUsername;Password=myPassword;Option=3;

Remote database

    | Driver={MySQL ODBC 3.51 Driver};Server=myServerAddress;Database=myDataBase;
    | User=myUsername;Password=myPassword;Option=3;
  
Specifying TCP/IP port

    | Driver={MySQL ODBC 3.51 Driver};Server=myServerAddress;Port=3306;
    | Database=myDataBase;User=myUsername;Password=myPassword;Option=3;
The driver defaults to port value 3306, if not specified in the connection string, as 3306 is the default port for MySQL.

MyODBC 2.50

Local database

    | Driver={mySQL};Server=localhost;Option=16834;Database=myDataBase;
      
Remote database

    | Driver={mySQL};Server=myServerAddress;Option=131072;Stmt=;Database=myDataBase;
    | User=myUsername;Password=myPassword;
      
Specifying TCP/IP port

    | Driver={mySQL};Server=myServerAddress;Port=3306;Option=131072;Stmt=;
    | Database=myDataBase;User=myUsername;Password=myPassword;

The driver defaults to port value 3306, if not specified in the connection string, as 3306 is the default port for MySQL.

Connection Visual Basic 6.0 to Microsoft Access 2010

Microsoft ACE OLEDB 12.0

Standard Security

    | Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccessFile.accdb;
    | Persist Security Info=False;

With database password
This is the connection string to use when you have an Access 2007 - 2013 database protected with a password using the "Set Database Password" function in Access.

    | Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccessFile.accdb;
    | Jet OLEDB:Database Password=MyDbPassword;

Some reports of problems with password longer than 14 characters. Also that some characters might cause trouble. If you are having problems, try change password to a short one with normal characters.
Note! Reports say that a database encrypted using Access 2010 - 2013 default encryption scheme does not work with this connection string. In Access; try options and choose 2007 encryption method instead. That should make it work. We do not know of any other solution. Please get in touch if other solutions is available!

Network Location

    | Provider=Microsoft.ACE.OLEDB.12.0;
    | Data Source=\\server\share\folder\myAccessFile.accdb;

Microsoft Jet OLE DB 4.0

Standard security

    | Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;User Id=admin;
    | Password=;

With database password

    | Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;
    | Jet OLEDB:Database Password=MyDbPassword;

Network Location

    | Provider=Microsoft.Jet.OLEDB.4.0;
    | Data Source=\\serverName\shareName\folder\myDatabase.mdb;User Id=admin;
    | Password=;

Microsoft Access accdb ODBC Driver

Standard Security

    | Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=C:\mydatabase.accdb;
    | Uid=Admin;Pwd=;

Exclusive

    | Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=C:\mydatabase.accdb;
    | Exclusive=1;Uid=admin;Pwd=;

Microsoft Access ODBC Driver

Standard Security

    | Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\mydatabase.mdb;Uid=Admin;Pwd=;

Exclusive

    | Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\mydatabase.mdb;Exclusive=1;
    | Uid=admin;Pwd=;