303factory
Registered User.
- Local time
- Today, 09:28
- Joined
- Oct 10, 2008
- Messages
- 136
Hi peeps
I'm having a problem where data is being truncated at the start when written into my table. It happens when updating a field with a string that is several thousand characters long. Apparently truncating at the start not the end is not normal behaviour for any database so im a bit confused as to how this is happening.
Details:
Back end: SQL Server 2008
Front end: MSAccess client
Tables linked using ODBC with SQL Server native client 10.0 driver
The field with the observed behavour is the type Nvarchar(MAX) which should theoretically hold 2GB data. If I change the field type to Nvarchar(4000) then the behaviour does not occur, and my client automatically truncates it to the field size at the end instead of the beginning
Code:
Connection declaration (global variable)
The error occurs in this body of code
If I debug and look at the '.Fields("Message") = strMessageBody' line, then the strMessageBody contains the entire string, but if I look at the table after the .update then the data in the table has been truncated.
Our IT department have tested the server using INSERT code and have shown that the Nvarchar(MAX) field is functioning and capable of holding long strings.
Ive scoured the net but failed to find anything useful.. any ideas?
thanks in advance, 303.
I'm having a problem where data is being truncated at the start when written into my table. It happens when updating a field with a string that is several thousand characters long. Apparently truncating at the start not the end is not normal behaviour for any database so im a bit confused as to how this is happening.
Details:
Back end: SQL Server 2008
Front end: MSAccess client
Tables linked using ODBC with SQL Server native client 10.0 driver
The field with the observed behavour is the type Nvarchar(MAX) which should theoretically hold 2GB data. If I change the field type to Nvarchar(4000) then the behaviour does not occur, and my client automatically truncates it to the field size at the end instead of the beginning
Code:
Connection declaration (global variable)
Code:
Set gSQLdbase = New ADODB.Connection
With gSQLdbase
.ConnectionString = "Provider=SQLNCLI10;Server=" & [serverip] & ";Database=[databaseName];Uid=[logon]; Pwd=[password];"
.Open
End With
The error occurs in this body of code
Code:
Dim strMessageBody as string
Dim rstRS As ADODB.Recordset
Dim strSQL As String
strSQL = "SELECT * FROM tblMessages WHERE 1=0"
Set rstRS = New ADODB.Recordset
rstRS.Open strSQL, gSQLdbase, adOpenKeyset, adLockOptimistic, adCmdText
' [loop through XML nodes]
With rstRS
.AddNew
strMessageBody = [string read from an xml file]
.Fields("Message") = strMessageBody
End With
'[end loop]
rstRS.Update
rstRS.Close
set rstRS = nothing
If I debug and look at the '.Fields("Message") = strMessageBody' line, then the strMessageBody contains the entire string, but if I look at the table after the .update then the data in the table has been truncated.
Our IT department have tested the server using INSERT code and have shown that the Nvarchar(MAX) field is functioning and capable of holding long strings.
Ive scoured the net but failed to find anything useful.. any ideas?
thanks in advance, 303.