I need fetch data from an MS Access database using a SQL query in a VB program.
The result is stored in a recordset, one of the fields is f100
, it's calculated by connecting multiple strings.
If the length of f100
's value is less than 255, the result is correct, but if it's longer than 255, the result is wrong: f100
just remains 255 characters in length and subsequent characters disappear.
My SQL statement is like this:
Select iif(f1=1,'123','')+iif(f2=1,'456','')+...... as f100 from Table1
My program is like this:
Dim Conn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim strConn$, strSQL$
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\try.mdb;Persist Security Info=False"
Conn.CursorLocation = adUseClient
Conn.Open strConn
strSQL="Select iif(f1=1,'123','')+iif(f2=1,'456','')+...... as f100 from Table1"
With rst
.CursorType = adOpenStatic
.LockType = adLockOptimistic
.CursorLocation = adUseClient
.Open strSQL, Conn
End With
'here rst.fields("f100") remains a max of 255 char
'debug.print rst.fields("f100")
rst.Close
Conn.Close
Is there any solution that hold a long calculated string in recordset just by SQL query?