Hello.
I have an ASP.NET application where I allow the user to upload attachments.
I upload the attachments as binary data to an image column in sql server. I
have managed to upload the data correctly. However, I need to be able to set
binary field back to NULL if the user wants to delete an attachmnet. What is
the proper way to do this? Thanks in advance.
I currently receive the following error.
Prepared statement '(@attachment nvarchar(4000), @attchmentMimeType
nvarchar(4000), @' expects a parameter @attachment, which was not supplied.
when I do the following.
string update = "UPDATE ResponseDetails SET attachment=@attachment, " +
"attachmentFileName=@attachmentFileName,
attachmentMimeType=@attachmentMimeType, " +
"lastModBy=@lastModBy, lastModUtcDate=@lastModUtcDate " +
"WHERE responseSessionId=@responseSessionId AND
questionId=@questionId";
SqlCommand sqlCmd = new SqlCommand(update, sqlConn);
sqlCmd.Parameters.Add("@attachment", DBNull.Value);
Or the error
Operand type clash: nvarchar is incompatible with image
when I do the following
string update = "UPDATE ResponseDetails SET attachment=@attachment, " +
"attachmentFileName=@attachmentFileName,
attachmentMimeType=@attachmentMimeType, " +
"lastModBy=@lastModBy, lastModUtcDate=@lastModUtcDate " +
"WHERE responseSessionId=@responseSessionId AND
questionId=@questionId";
SqlCommand sqlCmd = new SqlCommand(update, sqlConn);
sqlCmd.Parameters.Add("@attachment", null);
Ryan Taylor 2 2786
You might get a better response posting to a SQL newsgroup. If I knew
the answer, I would tell you though.
"Ryan Taylor" <rt*****@stgeorgeconsulting.com> wrote in message
news:es**************@TK2MSFTNGP15.phx.gbl... Hello.
I have an ASP.NET application where I allow the user to upload
attachments. I upload the attachments as binary data to an image column in sql server.
I have managed to upload the data correctly. However, I need to be able to
set binary field back to NULL if the user wants to delete an attachmnet. What
is the proper way to do this? Thanks in advance.
I currently receive the following error.
Prepared statement '(@attachment nvarchar(4000), @attchmentMimeType nvarchar(4000), @' expects a parameter @attachment, which was not
supplied. when I do the following.
string update = "UPDATE ResponseDetails SET attachment=@attachment, " + "attachmentFileName=@attachmentFileName, attachmentMimeType=@attachmentMimeType, " + "lastModBy=@lastModBy, lastModUtcDate=@lastModUtcDate " + "WHERE responseSessionId=@responseSessionId AND questionId=@questionId";
SqlCommand sqlCmd = new SqlCommand(update, sqlConn); sqlCmd.Parameters.Add("@attachment", DBNull.Value); Or the error
Operand type clash: nvarchar is incompatible with image
when I do the following
string update = "UPDATE ResponseDetails SET attachment=@attachment, " + "attachmentFileName=@attachmentFileName, attachmentMimeType=@attachmentMimeType, " + "lastModBy=@lastModBy, lastModUtcDate=@lastModUtcDate " + "WHERE responseSessionId=@responseSessionId AND questionId=@questionId";
SqlCommand sqlCmd = new SqlCommand(update, sqlConn); sqlCmd.Parameters.Add("@attachment", null);
Ryan Taylor
A co-worker figured this one out. Simple really. The sql string became
string update = "UPDATE ResponseDetails SET attachment=null, " +
"attachmentFileName=null,
attachmentMimeType=null, " +
"lastModBy=@lastModBy, lastModUtcDate=@lastModUtcDate " +
"WHERE responseSessionId=@responseSessionId AND
questionId=@questionId";
Hard code the null values instead of trying to use parameterized lists.
-Ryan. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: PearCZ |
last post by:
Hi,
I am trying to store binary data (e. g. image) in MS SQL Server 2000 column
which data type is . I understand I could store binary data easily in
MS SQL type but I have only column...
|
by: Altemir |
last post by:
I have a table that contains the following two columns:
BITS (image(16))
BIT_LENGTH (int(4))
When I look at the table, I see "OLE Object" in the BITS column. What
syntax should I use in...
|
by: Bassem |
last post by:
Hi all
I saved my imaged in SQL 2000 server database and now I want to get
the values of the columns to text or xml file. The field I didn't
could get it to the text file is the Image column...
|
by: Josema |
last post by:
Hi to all,
I have stored in a database some binary files (pdfs, and gif images), i
would like to know how could i show it, in internet explorer when a person
enters for instance in a textbox the...
|
by: Simon Harris |
last post by:
Hi All,
I have a data grid which displays country names. I now wish to display the
country flag images above the names.
Can someone please advise how I display an image in a datagrid? I have a...
|
by: |
last post by:
Hi all, is there a better way to stream binary data stored in a table in sql
2005 to a browser in .net 2.0? Or is the code same as in .net 1.1? We
noticed that in certain heavy load scenarios,...
|
by: mleaver |
last post by:
I want to open a second window and display a binary image that is returned from
a java program via XMLRPC. The data returned is a binary encoded base64 png
file. If I write the data out to a file...
|
by: ivan.leben |
last post by:
How can I really delete a preloaded image from memory/disk cache? Let's
say I preload an image by creating an Image object and setting its src
attribute to desired URL:
var img = new Image();...
|
by: raptureathand |
last post by:
How can i binary serialize objects on MySQL
also can you provide a step by step approach of running the program below and which software and platform do i need to get the program working;
using...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |