I want to save file to my SQL Server; the column type is varbinary(max)
.
When I try to save, I get an error:
Cannot create a row of size 8091 which is greater than the allowable maximum row size of 8060.
This is the code
Using fs As New IO.FileStream(OpenFileDialog2.FileName, IO.FileMode.Open, IO.FileAccess.Read)
If fs.Length <= Int32.MaxValue Then
Dim bytes(CInt(fs.Length - 1)) As Byte
fs.Read(bytes, 0, CInt(fs.Length))
Dim docfile As New SqlParameter("@d39", SqlDbType.VarBinary)
docfile.Value = bytes
cmd.Parameters.Add(docfile)
End If
End Using
from OP's comment: Table Schema:
CREATE TABLE [dbo].[empolyee] (
[Emp_code] [int] NOT NULL
,[arabicname] [nchar](250) NOT NULL
,[worktime] [nvarchar](250) NULL
,[filedata] [varbinary](max) NULL
,CONSTRAINT [PK_empolyee] PRIMARY KEY CLUSTERED ([Emp_code] ASC) WITH (
PAD_INDEX = OFF
,STATISTICS_NORECOMPUTE = OFF
,IGNORE_DUP_KEY = OFF
,ALLOW_ROW_LOCKS = ON
,ALLOW_PAGE_LOCKS = ON
) ON [PRIMARY]
) ON [PRIMARY] GO