Error saving NVarChar field


Author
Message
Larry Caylor
Larry Caylor
StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)
Group: Awaiting Activation
Posts: 592, Visits: 3.7K

I’m getting the following error when trying to save a NVarChar field with a maximum size greater than 2000 although the maximum for SQL Server 2005 is 4000.

 

In the code that caused the error al_UserNote was configured as nvarchar(2048). Looking at the partial class it looks like field lengths are being doubled by BOMapper when it creates the class. If you use NVarChar(MAX) there is no error since the length is set to -1.

 

-Larry

 

 

 MicroFour.StrataFrame.Data.DataLayerSavingException was unhandled by user code

  Message="The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 11 ("@al_UserNote"): Data type 0xE7 has an invalid data length or metadata length."

  Source="MicroFour StrataFrame Business"

  StackTrace:

       at MicroFour.StrataFrame.Business.BusinessLayer.Save(Boolean Transactional, String TransactionKey)

       at MicroFour.StrataFrame.Business.BusinessLayer.Save()

       at WindowsForms.CoverSheet.SaveAllOnTransaction() in C:\HRADevelopment-SFv1.5\ScanTracker\WindowsForms\CoverSheet.vb:line 188

       at WindowsForms.CoverSheet.btnPrint_Click(Object sender, EventArgs e) in C:\HRADevelopment-SFv1.5\ScanTracker\WindowsForms\CoverSheet.vb:line 118

       at System.Windows.Forms.Control.OnClick(EventArgs e)

       at System.Windows.Forms.Button.OnClick(EventArgs e)

       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)

       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)

       at System.Windows.Forms.Control.WndProc(Message& m)

       at System.Windows.Forms.ButtonBase.WndProc(Message& m)

       at System.Windows.Forms.Button.WndProc(Message& m)

       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)

       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)

       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

 

StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
According to all of the SQL Server documentation and testing that we have done, we determined that the Size property of the SqlParameter specified the maximum number of bytes that the parameter should be allowed to hold.  Since each Unicode character is 2 bytes, we doubled NVarChar and NChar lengths, but not VarChar or Char... I'll check into this and see what I can do.
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Nope, you are correct... "For nonstring data types and ANSI string data, the Size property refers to the number of bytes. For Unicode string data, Size refers to the number of characters."

I'll get it changed.

Larry Caylor
Larry Caylor
StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)
Group: Awaiting Activation
Posts: 592, Visits: 3.7K
Thanks!

-Larry

StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
I'm trying to find where that value is set right now... I think we're pulling it directly from the OCTET_LENGTH property on the database.  So, rather than taking out the x2, we'll need to add a /2 to unicode character types.  Ermm
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
This being said, I don't know if this is going to make the build today until I can make sure it's correct for all of the databases... if I change it incorrectly on providers other than SQL Server, it could really short change some people, and I can't do that.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search