|
-
Jul 26th, 2004, 12:39 PM
#1
Thread Starter
Fanatic Member
Excel 255 character limit for a cell? [Resolved]
Hi.
I'm transferring data from an Excel spreadsheet to a SQL Server DB via ADO. The code works as expected, but all of the data is not transferred over if a cell contains more than 255 characters - in other words, it is truncated. Does anyone know why this is happening? Better yet, a solution for the problem! 
Thanks,
OneSource
Last edited by OneSource; Aug 2nd, 2004 at 12:55 PM.
-
Jul 27th, 2004, 03:25 AM
#2
At a guess the Sql server field is set to 255 max... either that or excel is as crap as I thought and its not letting you do it. 
Vince
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Jul 27th, 2004, 09:38 AM
#3
Thread Starter
Fanatic Member
Thanks Ecniv ....
The SQL Server field has a size of 4000 characters, so that rules out option 1! That only leaves option 2: "excel is as crap as I thought and its not letting you do it." 
Thanks anyway.
OneSource
-
Aug 2nd, 2004, 12:26 AM
#4
How are you transfering it to SQL? Could it be that you may be
using a variable of string type of default length 255? If you are
using the variable, then just declare it of a greater length. I
thought of this since you say that Excel has more than 255 chars
in a cell. This would lead me to believe that Excel can handle the
larger length. So it must be in your transfer code.
Ps. Excel can handle the larger length. Just checked.
Can you post some of your transfer code?
HTH
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 2nd, 2004, 09:18 AM
#5
Thread Starter
Fanatic Member
RobDog888 ...
Thanks for your response.
I was able to get around the problem by using a string array and a loop.
VB Code:
Public Sub Main()
Dim intLength As Integer
Dim strUpdateText() As String
Dim bytCtr As Byte
ReDim strUpdateText(0)
intLength = Len(Cells(1, 1).Text)
Do
strUpdateText(UBound(strUpdateText)) = Mid(Cells(1, 1).Text, (bytCtr * 255) + 1, 255)
bytCtr = bytCtr + 1
ReDim Preserve strUpdateText(UBound(strUpdateText) + 1)
intLength = intLength - 255
Loop Until intLength < 0
For bytCtr = 0 To UBound(strUpdateText) - 1
If bytCtr = 0 Then
'Update with strupdatetext(0)
strSQL = "UPDATE CultureProperties SET PropertyValue = '" & strUpdateText(bytCtr) & "' " & _
"WHERE refID = " & CInt(Cells(intRowCtr, 1)) & " AND Culture = 'fr'"
Else
'Append with current text and strupdatetext(bytctr)
strSQL = "UPDATE CultureProperties SET PropertyValue = PropertyValue + '" & strUpdateText(bytCtr) & "' " & _
"WHERE refID = " & CInt(Cells(intRowCtr, 1)) & " AND Culture = 'fr'"
End If
'Debug.Print strUpdateText(bytCtr)
Next
End Sub
I know it's cludgy, but it works. But I think you are right. I was using the default string type. When you refer to declaring the variable at greater length, do you mean something like this:?
Anyway, I was trying to figure this out for a co-worker and saw the problem on her PC. When I just tried to transfer the data using a string variable declared in the conventional way (Dim strUpdateText As String) on my PC, it worked! I don't know why it would work on mine and not hers. 
Anyway, thanks again!
-
Aug 2nd, 2004, 12:50 PM
#6
Thanks, and kind of what I meant. The way your have it is as a
string array. My way creates a string buffer of a length of 5000
characters. Then use Trim to remove any trailing spaces that you
don't need.
VB Code:
Dim strString As String * 5000
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 2nd, 2004, 12:54 PM
#7
Thread Starter
Fanatic Member
RobDog888 ...
Thanks!
-
Aug 2nd, 2004, 01:21 PM
#8
No prob.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|