Ok, I am at wits end and hope someone can help me because I cannot figure out this problem.
I have a RadUpload in a nestedviewtemplate of a RadGrid that I want to use to store PDF, XLS, DOC, etc. files to my database. At present I am using the development SQL Server Express 2008 with VS2008. Originally I went to fast and easy by using SQLDataSources to drive my grids and provide the select, update, and insert funcitonallity but intermittently received the error:
After searching around the Telerik site I stumbled on the Upload and open documents in a SQL database demo in the code library, took some time wrapping my head around the C# code and figured out what made it tick. This worked flawlessly for every file I tried to upload so I thought, this is it! I converted this demo app to work with my SQL Express table, added the extra fields I wanted stored with my data, popped a reference to the FileUpload.BLL into my application and finally got everything running as expected, well until I tried to upload a file and blast you implict conversion!
I then spent even more time researching the interweb for a possible solution to this problem and found some vague reference to converting the System.Link.Data.Binary to a byte[] array and changed the FileUpload.BLL line from:
private System.Data.Linq.Binary _FileBinary; to private byte[] _File_Data;
and then changed the inserting code from:
fileStorage.File_Data = new System.Data.Linq.Binary(file.File_Data);
to:
fileStorage.File_Data = (byte[])file.File_Data.ToArray();
I rubbed my hands together gleefully, fired up the app, inserted a file and.....BLAST IT, error again.
Well, now I am all out of ideas as to what is throwing this error and have no clue what to try next. Even with all of that, know what the kicker is? My record is apparently saving in the database and the binary data appears to be there since I can hit the back button, refresh the grid and there it is. So, please one of you smarter than me folks tell me what I can do to get this working, even if it is just surpressing this error. I REALLY need this database online to track my project.
I have a RadUpload in a nestedviewtemplate of a RadGrid that I want to use to store PDF, XLS, DOC, etc. files to my database. At present I am using the development SQL Server Express 2008 with VS2008. Originally I went to fast and easy by using SQLDataSources to drive my grids and provide the select, update, and insert funcitonallity but intermittently received the error:
Implicit conversion from data type nvarchar to varbinary(max) is not allowed. Use the CONVERT function to run this query.
After searching around the Telerik site I stumbled on the Upload and open documents in a SQL database demo in the code library, took some time wrapping my head around the C# code and figured out what made it tick. This worked flawlessly for every file I tried to upload so I thought, this is it! I converted this demo app to work with my SQL Express table, added the extra fields I wanted stored with my data, popped a reference to the FileUpload.BLL into my application and finally got everything running as expected, well until I tried to upload a file and blast you implict conversion!
I then spent even more time researching the interweb for a possible solution to this problem and found some vague reference to converting the System.Link.Data.Binary to a byte[] array and changed the FileUpload.BLL line from:
private System.Data.Linq.Binary _FileBinary; to private byte[] _File_Data;
and then changed the inserting code from:
fileStorage.File_Data = new System.Data.Linq.Binary(file.File_Data);
to:
fileStorage.File_Data = (byte[])file.File_Data.ToArray();
I rubbed my hands together gleefully, fired up the app, inserted a file and.....BLAST IT, error again.
Well, now I am all out of ideas as to what is throwing this error and have no clue what to try next. Even with all of that, know what the kicker is? My record is apparently saving in the database and the binary data appears to be there since I can hit the back button, refresh the grid and there it is. So, please one of you smarter than me folks tell me what I can do to get this working, even if it is just surpressing this error. I REALLY need this database online to track my project.