Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Handling very long strings

Posted on 2002-05-16
7
Medium Priority
?
154 Views
Last Modified: 2010-05-02
Hello Experts:

I have seem to run into a problem that I don't know how to handle.

I am using Sql 7.0 for the database backend, and I store very long strings in a field defined as text.  When I pull this data into a string variable, it only retrieves about 1300 characters of data.  Im not sure if its the field definition or the variable definition that I'm having a problem with.  As long as the data is smaller than 1300 characters, it works fine.

Any ideas?

Data is stored as such:

65000,65001,65002,65003,......

I pull this into a string variable then run a sql statement as such:

Select * from tablename where fieldname in (Variable).
0
Comment
Question by:escheider
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 5

Accepted Solution

by:
bob_online earned 200 total points
ID: 7014102
That's not what is happening.

when you use the In (list of items) syntax you are limited to 255 values in the list.  Note that 1300 / 5 = 260 so when you say about 1300 characters my guess is that it's really 1275 which, with 5 digit numbers, results in 255 items.

You're going to have to do something like this:

select * from tablename where fieldname in (Variable1) or fieldname in (Variable2) or fieldname in (variable3).

I'm assuming you're actually concatenating the string such as

"Select * from tablename where fieldname in (" & Variable1 & ") or fieldname in (" & Variable2 & ")"

If you know the max number of values, you can just dim the number of variables you need at design time.  Otherwise, I would use an array of strings and dynamically dimension it on the fly.  Then do something like

SQL = "Select * from tablename where "
For I = 1 to arrNames.Ubound
   SQL = SQL & "Fieldname in (" & arrNames(I - 1) & ") Or "
Next
SQL = Left$(SQL, Len(SQL) - 4) ' to cut of the last " or "
0
 
LVL 5

Expert Comment

by:bob_online
ID: 7014123
To continue, you can build the array like this

done = false
ArrayIndex = -1
While not done
   redim preserve arrNames(arrNames.Ubound + 1)
   ArrayIndex = ArrayIndex + 1
   arrNames(ArrayIndex) = Left$(StringFromDatabase, 1275)
   StringFromDatabase = Mid$(StringFromDatabase, 1276)
   If Len(StringFromDatabase = 0 Then
      Done = True
   End If
Wend
0
 
LVL 4

Expert Comment

by:trkcorp
ID: 7014128
ASSUMING ADO:
You probably need to use the GetChunk method for retrieving the data... This is well documented.  Look up ADO/data types/managing long data types in your help files
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 5

Expert Comment

by:bob_online
ID: 7014130
Finally, the 1275 value in my parsing routine won't work because it isn't allow for commas but you can easily calculate the corrrect value.

0
 
LVL 1

Expert Comment

by:eosu
ID: 7023677
don't use getchunck - use ADO streams.
0
 
LVL 4

Author Comment

by:escheider
ID: 7060375
Sorry its been awhile since I've checked on this, my wife is pregnant and haven't dedicated time to this site.

eosu, please give me an example on ADO streams..
0
 
LVL 4

Author Comment

by:escheider
ID: 7063837
Decided to close this question.  I used your example and it works just fine...thanks for your time and input
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question