variable-length string

Anybody come accross this before?

I'm building a string like this:

Dim strUpdate

strUpdate = "update MY_TABLE " & _
              "set " & _
              "COL1 = " & strExportData(4) & ", " & _
              "COL2 = " & strExportData(5) & ", " & _
              "COL3 = " & strExportData(6) & ", " & _
              "COL4 = " & strExportData(7) & ", " & _
              "COL5 = " & strExportData(8) & ", "
  strUpdate = strUpdate & _
              "COL6 = " & strExportData(9) & ", " & _
              "COL7 = " & strExportData(10) & ", " & _

and so on. (There are 230 columns in total.)

My problem is that once the string gets 255 characters in it, it stops growing.

Grateful for any help!

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

From the MSDN help files:

String Data Type

There are two kinds of strings: variable-length and fixed-length strings.

A variable-length string can contain up to approximately 2 billion (2^31) characters.

A fixed-length string can contain 1 to approximately 64K (2^16) characters.
Note   APublic fixed-length string can't be used in aclass module.

The codes forString characters range from 0–255. The first 128 characters (0–127) of the character set correspond to the letters and symbols on a standard U.S. keyboard. These first 128 characters are the same as those defined by theASCII character set. The second 128 characters (128–255) represent special characters, such as letters in international alphabets, accents, currency symbols, and fractions. Thetype-declaration character for String is the dollar sign ($).
It may be that your database engine does not support SQL statements which are more than 255 characters.  If this is an Access db than that is definitely the case.  Because Dr.Delphi is right string data-types do hold more characters but using this size of a string is your problem, I would guarantee it.

You might just have to look at making two or three different statements and then executing them.
When i saw your question i thought it was because of the strUpdate declaration but i tried to remake the problem and wrote the following code:

Dim a
Dim s As String
Dim i As Integer

a = ""
For i = 0 To 2000
  a = a & i Mod 10
  s = s & i Mod 10

Debug.Print "a = " & Chr(34) & a & Chr(34)
Debug.Print "len(a) = " & Len(a)
Debug.Print "s = " & Chr(34) & s & Chr(34)
Debug.Print "len(s) = " & Len(s)

In both cases the variable didn't stop to grow.
i sugest you to execute this code on your machine and watch what hapens, then tell me if the len of 'a' and 's' isn't 2001

but i still think the problem is on declaration
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Are you displaying the screen in some way that limits what you see, or is a control character getting in there.  Check out the len(strupdate)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Your problem is that you didn't declare the variable a STRING, but a variant.
Declare it as string !

Dim strUpdate as String
doghundAuthor Commented:
The problem was pretty dumb. When I ran the SQL string there was an error. So I debugged to see what was written in the string using 'Add Watch'.
This shows only the first 255 chars of the string.
Using the Imediate window and writing
'?strUpdate' I got the entire string and when I ran the sql string direct in the DB I found that the problem was a constraint which had been broken.
I honestly thought that I had found a bug in VB. Sorry about that, and thanks for your help.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.