Hi,
I am facing strange problem while accessing a LONGTEXT
field.
I've been using VisualBasic 6.0 & MySQL 4.0.4 via ADO
2.0 by using MyODBC 3.51.04 on WIN2k Server (SP 2).
Pls follow the below steps to generate a bug -->
'/////////////////////////////////////////////////////'
1. Create a Table for testing
'* Script to generate the table and insert a record *'
USE TEST;
CREATE TABLE Testing
(
ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
msg LONGTEXT NOT NULL ,
fld2 INT NOT NULL
) TYPE=InnoDB;
INSERT INTO Testing(msg,fld2)
VALUES("",1);
2. Create a VB Project
'***************** VB CODE ***************** '
'Step to create a VB project
'a. Open a new VB project
'b. Add reference of ADO 2.0
'c. By default New form will be added to the project
'd. Copy the below code in it
Option Explicit
Private mcnn As New ADODB.Connection
Private Sub Form_Load()
On Error GoTo DispError
Dim rst As New ADODB.Recordset
Dim strSQL As String
'change below connection string as per your db
settings
mcnn.Open "Driver={MySQL ODBC 3.51
Driver};SERVER=server;DB=test;UID=root;PWD=;OPTION=3"
strSQL = "SELECT * FROM Testing"
'*** Method 1. Client side recordset ***'
' If 'msg' field has blank string - below
code will give error while trying
' to access Recordcount property, and
strangely Recordpointer is at EOF
' If 'msg' field has value other than blank
string & NULL then it will run properly
With rst
Set .ActiveConnection = mcnn
.CursorLocation = adUseClient
.CursorType = adOpenKeyset
.LockType = adLockPessimistic
.Open Source:=strSQL, Options:=adCmdText
'Normally below statement should return 1 but
on my m/c
'it generates E_FAIL status error.
MsgBox .RecordCount
'it will display -1 as record pointer is at
EOF, Strange?
MsgBox "Record pointer: " & .AbsolutePosition
End With
Set rst = Nothing
'****************************************'
'*** Method 2. Server side recordset ***'
' If 'msg' field has blank string -
below code will return NULL
' If 'msg' field has value other than
blank string & NULL then it will return blank string
Set rst = mcnn.Execute(CommandText:=strSQL,
Options:=adCmdText)
MsgBox "Msg: " &
IIf(IsNull(rst.Fields("msg").Value), "<NULL>",
rst.Fields("msg").Value)
'****************************************'
Exit Sub
DispError:
MsgBox Err.Description, vbCritical
Resume Next
End Sub
'** END OF VB CODE **'
'/////////////////////////////////////////////////////'
3. run the project. It will display 3 messagebox. On
my m/c it display following messages
MsgBox 1 --> Data provider or other service returned
an E_FAIL status.
MsgBox 2 --> Record Pointer: -1
MsgBox 3 --> Msg: <NULL>
Any help is appreciated.
- DEEP
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php