Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Retrieve SQL Text fields into VB
Message
 
To
All
General information
Forum:
Visual Basic
Category:
Database DAO/RDO/ODBC/ADO
Title:
Retrieve SQL Text fields into VB
Miscellaneous
Thread ID:
00463819
Message ID:
00463819
Views:
54
Hi,

I've created a link to Word 8 for a 3rd party helpdesk app (HEAT).
Due to a constraint where the calling program has to pass a command line argument to the program (not possible in VBA) I have used SQL procedures called by the VB program, with parameters passing as needed. VB then launches a copy of word, creates a temporary table in word and assigns the retrieved database values to it. This Word table becomes the data source for the merge and everything works well.
Now I need to include a SQL text(memo) datatype field in the merge.
I've written the SQL proc. which works great in Query Analyser.
I can establish connection to the database via VB, but I cannot get the data into VB! I understand the need to treat this data as a Recordset object, but as shown in the test code below it only results in error 3265.
"Item cannot be found in the collection corresponding to the requested name or ordinal".

Code listing:
Private Sub AdoReadMemo()

Dim strCnn3 As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim sNotes As String
Dim sChunk As String
Dim cchChunkReceived As Long
Dim cchChunkRequested As Long
Dim cnn3 As String

'Open the connection
strCnn3.Open "dsn=GMSvc_Support Data;" & "UID=goldmine"
' Open the recordset
rst.Open "SELECT QACompile From Calllog where CallId =" & Command, _
strCnn3, adOpenKeyset, adLockReadOnly
Debug.Print rst!callid
'cchChunkRequested artifically set low at 16
' to demonstrate looping
cchChunkRequested = 16
If Not rst.EOF And Not rst.BOF Then
' Loop through as many chunks as it takes
' to read the entire BLOB into memory
Do
'Temporarily store the next chunk
sChunk = rst.Fields("QACompile").GetChunk(cchChunkRequested)

' Check how much we got
cchChunkReceived = Len(sChunk)

' If we got anything,
' concatenate it to the main BLOB
If cchChunkReceived > 0 Then
sNotes = sNotes & sChunk
End If

Loop While cchChunkReceived = cchChunkRequested
Else: MsgBox "There is no record!"
End If
' For this example, print the value of
' the Notes field for just the first record
Debug.Print sNotes

' Close the recordset
rst.Close

'Call Wordmerge
End Sub
Just because you can't see it, doesn't mean it's not there!
Reply
Map
View

Click here to load this message in the networking platform