Hi all
This is not a Telerik issue, I just need some pointers.
Using the examples in the help, I have distilled the problem down to the following code, ie no error trapps or validation controls.
I get the error - Value of type '1-dimensional array of Byte' cannot be converted to 'Byte'
On the 'bytes' in the ModelImageAdd function. Why is this, what am I missing?
The function to save the image data looks like this:
This is not a Telerik issue, I just need some pointers.
Using the examples in the help, I have distilled the problem down to the following code, ie no error trapps or validation controls.
I get the error - Value of type '1-dimensional array of Byte' cannot be converted to 'Byte'
On the 'bytes' in the ModelImageAdd function. Why is this, what am I missing?
Protected Sub btnUpload_Click(sender As Object, e As System.EventArgs) Handles btnUpload.Click BindValidResults() End Sub Protected Sub BindValidResults() If RadUpload1.UploadedFiles.Count > 0 Then For Each file As UploadedFile In RadUpload1.UploadedFiles Dim bytes(file.ContentLength - 1) As Byte file.InputStream.Read(bytes, 0, file.ContentLength) Dim a As New Model a.ModelImageAdd(Model_ID, file.GetName(), bytes, Owner_GUID) Next End If End SubThe function to save the image data looks like this:
Public Function ModelImageAdd(ByVal _Model_ID As String, _ImageName As String, ByVal _ImageData As Byte, ByVal _Owner As Guid) As Boolean Try Using sqlConn As New SqlConnection(ConfigurationManager.ConnectionStrings("cnModelDB").ToString) Using sqlCmd As New SqlCommand() With sqlCmd .CommandType = CommandType.StoredProcedure .CommandText = "ModelImageAdd" .Connection = sqlConn .Parameters.Add("@Model_ID", SqlDbType.Int).Value = _Model_ID .Parameters.Add("@ImageName", SqlDbType.VarChar, 75).Value = _ImageName .Parameters.Add("@ImageData", SqlDbType.Binary).Value = _ImageData .Parameters.Add("@Owner", SqlDbType.UniqueIdentifier).Value = _Owner .Parameters.Add("@ReturnValue", SqlDbType.Int).Direction = ParameterDirection.ReturnValue .Connection.Open() .ExecuteScalar() End With If sqlCmd.Parameters("@ReturnValue").Value = 0 Then ModelImageAdd = 1 Else ModelImageAdd = sqlCmd.Parameters("@ReturnValue").Value End If End Using End Using Catch ex As Exception ErrorLog.Log(String.Format("Model:ModelAdd(): {0}", ex.Message)) Return False End TryEnd Function