Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > Saving binary file data to SQL server
 

Saving binary file data to SQL server

I'm trying to save the data from a binary file of unknown type and size to SQL server.

Code Block

cmd.Parameters.Add(new SqlParameter(

"@filedata",

SqlDbType.VarBinary,

filebytes.Length,

ParameterDirection.Input,

false,

0, 0, "",

DataRowVersion.Current,

filebytes));

This parameter is part of the following StoredProcedure:

Code Block

PROCEDURE [SCHEMA NAME REMOVED].[spStoreBankReport]

@filedate DATETIME,

@filename VARCHAR(55),

@filedata VARBINARY(MAX)

AS

INSERT INTO PositivePay.tblBankReport VALUES(@filedate,@filename,@filedata)

However, when it runs, I get an error that there's the procedure has too many arguments. I've made sure to fill out similar SqlParameter objects for all three parameters...

Tom Shirk  Friday, December 14, 2007 9:12 PM
Whynot using the Image data type instead of VarBinary in the database? This article may help you.
Zhi-Xin Ye  Tuesday, December 18, 2007 9:31 AM
Whynot using the Image data type instead of VarBinary in the database? This article may help you.
Zhi-Xin Ye  Tuesday, December 18, 2007 9:31 AM

You can use google to search for other answers

Custom Search

More Threads

• datagridview select cell
• Extending the functionality of the table classes generated by Visual Studio Dataset Designer
• DataGridView Combo Column (extended combobox)
• Creating new master record when adding detail via dialog
• Binding TextBox to integer field
• Need event in WinForms equal to "ItemUpdating" in WebForms
• Why HitTest does not work in DragOver in DataGridView
• Catching a change event on a bound cell
• DataGridView RowValidating event causes crash when leaving SplitContainer panel
• DataGrid Problems