VB 2010 Advantage Database Example

Sybase Advantage Database With Visual Basic .Net 2010

Update Sybase Advantage Database using XML file from Visual Basic 2010 [Client-Server] Idea.
Update Sybase Advantage Database using XML file from Visual Basic 2010 [Client-Server] Idea.

1. Create New Visual Basic 2010 WinForm Application Project
2. Path to Project (I.e. D:\MySyBase\)
3. Path to Database (I.e. D:\MySyBase\Bin\Debug\)
4. Sybase Advantage Database (MyDB.add)
5. Sybase Advantage Database Username : AdsSys - Password : ahmed
6. Sybase Advantage Database Table (I.e. MyInfo.adt)

We will create a personal Info application, so the table structure will be like that :

Sybase Advantage Database
Visual Basic 2010 - Sybase Advantage Database

Note : All other fields will vary in [Size] only but all fields are [cicharacter] Data Type.

Visual Basic Form Design :

Visual Basic 2010
Visual Basic Online Courses

Note : I have made TextBoxes with Naming convention (I.e NameTxt, EmailTxt, MobileTxt .... etc). Also I've placed 1 DataGridView and some Buttons. I also have 1 Module [Module1].

SaveBtn : Save new record to the Advantage Database
SearchBtn : Search for records using by Sname
EditBtn : After search, edits the record
DeleteBtn : After search, deletes the record
CancelBtn : Reset the form and the DataGridView
ExitBtn : Exits the application

In order to use Sybase Advantage Database with Visual Basic 2010 and just like any other Database, you must call the References Advantage.Net Data Provider.

Update for Visual Studio 2015 : Download Advantage Data Provider 11.10.30

The installation file dataprovider.exe, installs :

  1. Advantage CA-Clipper RDDs
  2. Advantage CA-Visual Objects RDDs
  3. Advantage Client Engine API
  4. Advantage Crystal Reports Driver
  5. Advantage Data Architect
  6. Advantage JDBC Driver
  7. Advantage .NET Data Provider
  8. Advantage ODBC Driver
  9. Advantage OLE DB Provider (for ADO)
  10. Advantage TDataSet Descendant
  11. Advantage Delphi Components
  12. Advantage Web Platform
  13. Advantage Python Interface
  14. Advantage Rudy Interface
  15. Advantage Perl DBI Driver
  16. Advantage PHP Extension

Visual Basic 2010 - Add Reference to Sybase Advantage Database
Visual Basic 2010 - Add Reference to Sybase Advantage Database

The Codes
Module1

Form1
Sub ClearAll()
Private Sub Form_Load()
Private Sub ExitBtn_Click()
Private Sub SaveBtn_Click()
Private Sub SearchBtn_Click()

Private Sub CancelBtn_Click()
Private Sub EditBtn_Click()
Private Sub DeleteBtn_Click()

Note : You will need 2 Pictures PNG [On : Off] to refer to the Database Status, path [..Bin/Debug].

Another Lesson : How to Remote Database using XML :

1) Create an XML file in path [.\bin\Debug\] Folder and call it [XmlFile.xml]
2) Open [XmlFile.xml] with NotePad.exe and paste the following code into it :

3) Save the Xml file.
4) Open our VB 2010 Project and add a ToolStrip to the Form1, Dock = Buttom

ToolStrip VB 2010 Xml Database Update
ToolStrip VB 2010 Xml Database Update

5) How does it work "The Main Idea" : When you want to Alter structure or Edit the Advantage Database of your Advantage Database "DB.Add" on a Client's "User's" computer you will need to do something like what I did, easy and guaranteed. Find a Server and send SQL Statements to the Xml File and when the user checks for update [Check For Update] button, the application will open the XmlFile.xml and execute the Sql-Statement within, simply like that. When you use Version Number along with the update, it makes the Update process so easy to be tracked, so we will need to create and extra Database Table in the Advantage Database and call it [DB_Version].

6) DB_Version table structure :
Update Advantage Database [MyDB.Add] using XML and Visual Basic 2010
Update Advantage Database [MyDB.Add] using XML and Visual Basic 2010

Note : UpdateDT column is Date DataType.

7) Now each time you send updates to XML file, the user Checks for update and choose the XML file from Open Dialog Box and it compares the Date and Version of the Update, if New then it executes the Sql Statement line, if not, then it gives message [MsgTxt.Text] You're Up-To-Date.
8) Download Example from MediaFire.com [Testing.ZIP]

AdsConnection GetSchema tip :

How to retrieve Advantage Data Dictionary Schema in VB 2010.
VB 2010 GetSchema - Retrieve Tables, Columns From Ads Data Dictionary (AdsConnection)
VB 2010 GetSchema - Retrieve Tables, Columns From Ads Data Dictionary (AdsConnection)

Advantage Data Types conversion in VB 2010

Type

Length

Available in DBF Table

VB 2010 Value

Character
1 to 65530
Yes
4
CICharacter
1 to 65530
No
20
Date
4
Yes
3
Logical
1
Yes
1
Memo
9
Yes
5
Double
8
VFP, Extended
10
Integer
4
VFP, Extended
11
Numeric
2 to 32
Yes
2
Image
9
Extended
7
Binary
9
Extended
6
ShortInteger
2
No
12
Time
4
No
13
TimeStamp
8
No
14
AutoIncrement
4
No
15
Raw
1 to 65530
No
16
CurDouble
8
No
17
Money
8
No
18
ModTime
8
No
22
RowVersion
8
No
21

Best Use, For example :

When you try to Retrieve Advantage Data Dictionary Table Structure you will get column names, and you will may need to retrieve Data Types [Field_Type], Advantage Data Arc. provides System.Columns Field_Type column within the System.Columns Table that return values like [Character], now when you do that in Visual Basic 2010 or any Visual Basic .Net version, you will not get [Character] but you will get [4] instead and you will want to convert it into [Character] name, you can do that using a function or a Select Case expression in VB 2010.

So, in order to retrieve Field_Type or DataType of a certain column in Advantage Database, you may use this code:

Some Exceptions and Errors noticed :

Error : 
Table doesn't appear in the Data Dictionary [ARC.exe] but though it appears in the Data Dictionary Folder.
Description :
When you try to create a free Table [ADT Table] using Sql Statement from VB 2010 like this. The result will be a free Table but not included in the Data Dictionary, but you will only see it in the Folder contains the Database.
Cause :
The User Id section in the connectionString is Empty, but if you tried to create another table with the same name you will get an Error specifying that ISAM found a table with the same name "Table already exists" though it doesn't appear in the Data Dictionary.
Solution :
Provider a User ID or a User Id and Password if possible in the connectionString Whether you are using OleDBConnection or AdsConnection to work with this Data Dictionary.

Here are some online Visual Basic lessons and courses :

Popular posts from this blog

Visual Basic Online Courses DataGridView Add Edit Delete

VB .NET WebView2 WinForms tips

Visual Basic 2010 Working With DataBase Full Project Example

VB NET Check internet connection

Visual Basic .Net - Button Sound / Music Play

Visual Basic 2010 Math Functions