[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

What is this error telling me I am doing wrong.

Posted on 2012-04-12
9
Medium Priority
?
268 Views
Last Modified: 2012-04-29
I am using this code in a script that uploads files to an SQL 2008 server. It produces an error that I can not figure out. What is this error telling me I am doing wrong. As far as I know I am passing these values in my script.

ERROR
The parameterized query '(@fileData varbinary(max) ,
@fileGuid uniqueidentifier,
@fileName ' expects the parameter '@fileData',
 which was not supplied.

SCRIPT
    Const SQL_INSERT As String = "INSERT INTO [imageFile] ([fileGuid],[fileName],[fileData],[fileId])" & _
                                                  "values (@fileGuid, @fileName, @fileData); select @fileId = SCOPE_IDENTITY()"

               cmdInsert.Parameters.Add("@fileData", SqlDbType.VarBinary, -1)

                cmdInsert.Parameters.Add("@fileGuid", SqlDbType.UniqueIdentifier)
                cmdInsert.Parameters("@fileGuid").Value = file.fileGuid

                cmdInsert.Parameters.Add("@fileName", SqlDbType.VarChar, 256)
                cmdInsert.Parameters("@fileName").Value = file.newFileName

                cmdInsert.Parameters.Add("@fileId", SqlDbType.BigInt)
                cmdInsert.Parameters("@fileId").Direction = ParameterDirection.Output
0
Comment
Question by:ruffone
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 33

Expert Comment

by:knightEknight
ID: 37839620
at first glance it looks like you are specifying 4 columns in the insert list, but only 3 values:

INSERT INTO [imageFile] ([fileGuid], [fileName], [fileData], [fileId])" & _
                            "values (@fileGuid, @fileName, @fileData)
0
 
LVL 20

Expert Comment

by:BuggyCoder
ID: 37839661
assign a value to @filedata parameter like this:-

  cmdInsert.Parameters("@fileData").Value = <SomeFileBinaryData>
0
 
LVL 4

Author Comment

by:ruffone
ID: 37840187
If I must use a value I only want to pass a single byte(). How do I assign a single byte()
0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
LVL 10

Expert Comment

by:adriankohws
ID: 37843663
So long your codes behind changed the data into binary, it doesn't matter so long it doesn't exceed the maximum size allowed.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 37853667
Try changing

 cmdInsert.Parameters.Add("@fileData", SqlDbType.VarBinary, -1)

to

 cmdInsert.Parameters.Add("@fileData", SqlDbType.VarBinary, System.Text.Encoding.ASCII.GetBytes(" "))
0
 
LVL 4

Author Comment

by:ruffone
ID: 37857159
This is a project that I am moving from my VS10 development environment into VS11 Beta DE. while tweaking my classes. I did not figure out what caused the error but when I reimported my bits from VS10 into VS11 and made my changes incrementally I did not end up with the error. Thank you all for your responses
0
 
LVL 4

Author Comment

by:ruffone
ID: 37866926
I figured out that the upload process fails when I check "IsImage". When I comment that line then the the process completes successfully I have no ides why this happens


    If filePath.InputStream.Length > -1 Then
        _fileData = filePath.InputStream
        If IsImage(_fileData) = False Then
            Exit Sub
        End If
        ...
    End If

    Private Function IsImage(file As Stream) As Boolean
        Using bitmap As New Bitmap(file, False)
            If bitmap.RawFormat.Equals(ImageFormat.Bmp) Then
                Return True
                Exit Function
            End If
            If bitmap.RawFormat.Equals(ImageFormat.Jpeg) Then
                Return True
                Exit Function
            End If
            If bitmap.RawFormat.Equals(ImageFormat.Gif) Then
                Return True
                Exit Function
            End If
            If bitmap.RawFormat.Equals(ImageFormat.Png) Then
                Return True
                Exit Function
            End If
            If bitmap.RawFormat.Equals(ImageFormat.Tiff) Then
                Return True
                Exit Function
            End If
            If bitmap.RawFormat.Equals(ImageFormat.Icon) Then
                Return True
                Exit Function
            End If

            Return False
        End Using
    End Function
0
 
LVL 4

Accepted Solution

by:
ruffone earned 0 total points
ID: 37889326
0
 
LVL 4

Author Closing Comment

by:ruffone
ID: 37907553
Thanks guys
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how the fundamental information of how to create a table.

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question