How to Use OCX & ActiveX in
Visual Basic 6 with Data Binding
For Visual Basic 4.0, programmers can set the bindable property of the OCX/ActiveX to bind to a database table field. When the users change the record, the field value will be automatically put into the bindable property of the OCX/ActiveX. For example, you can bind the Text property of the TextBox control with a field of Text type in a table of a database.
In my products, the Animation GIF ActiveX can support data binding. The GIF property is bindable. You can bind the GIF picture with a database table field. Because in database, Text type doesn't support zero character, we should use Memo type to store the GIF picture.
And another problem is in Visual Basic 4/5/6, the data binding using DataControl doesn't support string that contains zero character. They look the zero character as the string end character and cut the characters after the zero character before passing the text to the ActiveX. Sometimes, the problem doesn't occur when using Remote Data Control as the binding control. The behavior is related to the ODBC driver you are using.
After wide testing, I found only the ADO Data Control using OLEDB technology can pass the correct Memo data to the ActiveX in any condition. So if you want to use data binding in my Animation GIF ActiveX. I suggest you to use Visual Basic 6.0 and the ADO Data Control 6.0.
To use data binding is very easy like following steps:
- Put a ADO Data Control onto your form and set the database, cursor, SQL/Table values using the ADO Data Control property pages.
- Put a ActiveX which has the bindable properties onto your form.
- You can see a DataBindings item in the "Properties Window" of the ActiveX. Click the "..." on the right of the item. You can get the dialog box which you can set the data bindings.
I am using Microsoft Visual Basic 6.0, Copyright© 1987, 1998 Microsoft Corporation.
Your comments and any suggestion are welcomed.
You can send me E-mail or sign my guest book.