Dear fellow sufferers...
I get the error noticed in the subjectline, while trying to put a 150MB
ZipFile into a SQL-2000-SP4-DB. This is the way I do it:
'***************************************
************************************
***********************
Public Function CYCLE__GisData_ZIP_Add(ByRef lCycleID As Long, _
ByVal sZipFile As String, _
ByRef sRetErrMsg As String) As Boolean
' Local Variables
Dim bError As Boolean
Dim sRetErrMsgSub As String
Dim fiZipFile As IO.FileInfo
Dim sSQL As String
Dim lFileLength As Long
Dim fileStream As IO.FileStream
Dim binReader As IO.BinaryReader
Dim binaryData() As Byte
Dim cmdSQL As SqlCommand
Dim paraSQL As SqlParameter
'-> reset return value
CYCLE__GisData_ZIP_Add = False
bError = False
sRetErrMsg = "Function: " & mc_sClassName & ".CYCLE__GisData_ZIP_Add"
Try
fiZipFile = New IO.FileInfo(sZipFile)
'-> save to Stream
fileStream = fiZipFile.OpenRead
binReader = New IO.BinaryReader(fileStream)
binaryData = binReader.ReadBytes(fileStream.Length)
lFileLength = fileStream.Length
binReader.Close()
fileStream.Close()
sSQL = "UPDATE tab_Cycle " + _
"SET GIS_Data = @.GIS_Data " + _
"WHERE (id = " & lCycleID & ")"
cmdSQL = New SqlCommand(sSQL, m_con_eRM_RFC)
paraSQL = New SqlParameter("@.GIS_Data", SqlDbType.Image)
paraSQL.Direction = ParameterDirection.Input
paraSQL.Value = binaryData
cmdSQL.Parameters.Add(paraSQL)
cmdSQL.ExecuteNonQuery()
Catch ex As System.Data.SqlClient.SqlException
Dim strSQLErr As String
Dim sqlErr As SqlError
For Each sqlErr In ex.Errors
strSQLErr = strSQLErr & sqlErr.ToString & vbNewLine
Next sqlErr
Throw New Exception(strSQLErr)
Catch ex As Exception
Throw New Exception(sRetErrMsg & sRetErrMsgSub & vbCrLf &
ex.ToString & vbCrLf)
Finally
'-> set return value
CYCLE__GisData_ZIP_Add = Not bError
End Try
End Function
'***************************************
************************************
***********************
All objects used are filled and the error occures on the
cmdSQL.ExecuteNonQuery(). There is no SQL-Errornumber or something like
that...
Any ideas or hints are welcome!
Cheers,
ChristophFor large binary streams, use a chunking method rather than sending the
entire value at once. See MSKB 317043
<http://support.microsoft.com/defaul...kb;en-us;317043> for an
examples.
Hope this helps.
Dan Guzman
SQL Server MVP
"Cheffe" <Cheffe@.discussions.microsoft.com> wrote in message
news:054F78D7-C8E9-405E-A67B-BB856074E090@.microsoft.com...
> Dear fellow sufferers...
> I get the error noticed in the subjectline, while trying to put a 150MB
> ZipFile into a SQL-2000-SP4-DB. This is the way I do it:
> '***************************************
**********************************
*************************
> Public Function CYCLE__GisData_ZIP_Add(ByRef lCycleID As Long, _
> ByVal sZipFile As String, _
> ByRef sRetErrMsg As String) As Boolean
> ' Local Variables
> Dim bError As Boolean
> Dim sRetErrMsgSub As String
> Dim fiZipFile As IO.FileInfo
> Dim sSQL As String
> Dim lFileLength As Long
> Dim fileStream As IO.FileStream
> Dim binReader As IO.BinaryReader
> Dim binaryData() As Byte
> Dim cmdSQL As SqlCommand
> Dim paraSQL As SqlParameter
>
> '-> reset return value
> CYCLE__GisData_ZIP_Add = False
> bError = False
> sRetErrMsg = "Function: " & mc_sClassName &
> ".CYCLE__GisData_ZIP_Add"
> Try
> fiZipFile = New IO.FileInfo(sZipFile)
> '-> save to Stream
> fileStream = fiZipFile.OpenRead
> binReader = New IO.BinaryReader(fileStream)
> binaryData = binReader.ReadBytes(fileStream.Length)
> lFileLength = fileStream.Length
> binReader.Close()
> fileStream.Close()
> sSQL = "UPDATE tab_Cycle " + _
> "SET GIS_Data = @.GIS_Data " + _
> "WHERE (id = " & lCycleID & ")"
> cmdSQL = New SqlCommand(sSQL, m_con_eRM_RFC)
> paraSQL = New SqlParameter("@.GIS_Data", SqlDbType.Image)
> paraSQL.Direction = ParameterDirection.Input
> paraSQL.Value = binaryData
> cmdSQL.Parameters.Add(paraSQL)
> cmdSQL.ExecuteNonQuery()
>
> Catch ex As System.Data.SqlClient.SqlException
> Dim strSQLErr As String
> Dim sqlErr As SqlError
> For Each sqlErr In ex.Errors
> strSQLErr = strSQLErr & sqlErr.ToString & vbNewLine
> Next sqlErr
> Throw New Exception(strSQLErr)
> Catch ex As Exception
> Throw New Exception(sRetErrMsg & sRetErrMsgSub & vbCrLf &
> ex.ToString & vbCrLf)
> Finally
> '-> set return value
> CYCLE__GisData_ZIP_Add = Not bError
> End Try
> End Function
> '***************************************
**********************************
*************************
> All objects used are filled and the error occures on the
> cmdSQL.ExecuteNonQuery(). There is no SQL-Errornumber or something like
> that...
> Any ideas or hints are welcome!
> Cheers,
> Christoph
>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment