| | |
Storing an Encrypted file in database
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
Hi, I was just wondering if anybody new of a way to store an encrypted file to an sql server database through a stored procedure. I have managed to encrypt a file selected from a FileUpload control but at the minute the encrypted file and the key are created and saved locally to the machine.
What I would like to be able to achieve is: under the one submit button have the file encrypted and then store the encrypted file and key to the database or force user A to browse for these files before submitting.
However, on execution I am getting an error stating that Input string was not in correct format and it is bugging out at the following line:
Below is a section of the code that I am using to try to save the encrypted file and key to the database (as varbinary)
Has anybody any ideas??
What I would like to be able to achieve is: under the one submit button have the file encrypted and then store the encrypted file and key to the database or force user A to browse for these files before submitting.
However, on execution I am getting an error stating that Input string was not in correct format and it is bugging out at the following line:
ASP.NET Syntax (Toggle Plain Text)
submitCommand.ExecuteReader();
Below is a section of the code that I am using to try to save the encrypted file and key to the database (as varbinary)
ASP.NET Syntax (Toggle Plain Text)
byte[] blobEcryptedFile = FileUpload_EncryptedFile.FileBytes; blobFile = blobEcryptedFile; byte[] blobPKey = FileUpload_Key.FileBytes; blobKey = blobPKey; //Actual filename of the file string filename = FileUpload_submitAss.FileName; submitCommand.Parameters.Add(new SqlParameter("@assignment", SqlDbType.VarBinary, blobFile.Length, ParameterDirection.Input, false, 0, 0, "Assignment", DataRowVersion.Current, blobFile)); submitCommand.Parameters["@assignment"].Value = blobFile; //The path to the encrypted file submitCommand.Parameters.Add(new SqlParameter("@filename", SqlDbType.NVarChar, 50, "Filename")); submitCommand.Parameters["@filename"].Value = filename; submitCommand.Parameters.Add(new SqlParameter("@publicKey", SqlDbType.VarBinary, blobKey.Length, ParameterDirection.Input, false, 0, 0, "pKey", DataRowVersion.Current, blobKey)); submitCommand.Parameters["@publicKey"].Value = blobKey; //The path to the key submitCommand.ExecuteReader(); submitCommand.Dispose(); myConnection.Close(); lbl_validation_submitAssignment.Text = "Your file has successfully been uploaded!";
Has anybody any ideas??
Last edited by Elmo_loves_you; Apr 19th, 2008 at 3:55 pm.
•
•
Join Date: Nov 2008
Posts: 1
Reputation:
Solved Threads: 0
Error : Input String was not in correct format.
Try this :
1. First set the parameter name and sql data type for sqlcommand.
2. Set value for the parameter name.
Ex:
Hope this will resolve your issue.
Share the knowledge and increase it....
Try this :
1. First set the parameter name and sql data type for sqlcommand.
2. Set value for the parameter name.
Ex:
asp.net Syntax (Toggle Plain Text)
sqlcommand.Parameters.Add("@Name",sqlDbType.varchar) sqlcommand.Parameters("@Name").value = value
Hope this will resolve your issue.Share the knowledge and increase it....
Last edited by peter_budo; Nov 28th, 2008 at 1:05 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
![]() |
Other Threads in the ASP.NET Forum
- Previous Thread: Main sending in Asp.net
- Next Thread: oledbDataAdapter.update exception: No value given for one or more required parameter
| Thread Tools | Search this Thread |
.net 2.0 activexcontrol advice ajax alltypeofvideos asp asp.net bc30451 bottomasp.net browser businesslogiclayer button c# c#gridviewcolumn checkbox child click commonfunctions compatible confirmationcodegeneration content contenttype courier css dataaccesslayer database datagrid datagridview datagridviewcheckbox datalist deadlock development dgv dropdownlist dropdownmenu edit expose feedback flash flv form formatdecimal forms formview gridview homeedition iframe iis javascript jquery listbox login menu microsoft mono mouse mssql multistepregistration news numerical objects order panelmasterpagebuttoncontrols parent radio ratings reportemail rotatepage save schoolproject search security serializesmo.table silverlight smartcard software sql-server sqlserver2005 suse textbox tracking typeof unauthorized validation vb.net video videos virtualdirectory vista visual-studio visualstudio web webapplications webarchitecture webdevelopemnt webprogramming webservice xml youareanotmemberofthedebuggerusers





