-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: sumanmukherji
Message 1 in Discussion

 
Hi All, 
  
I want to store file content inside a database field of type image from an ASP.net 
page via a web service method.<o:p></o:p> 
Now to do that, I have created an input control of type File and when the form is 
submitted to web server, the content is converted to binary array. Now I want to store 
this binary content to a database field of type image. While doing that, all file 
types other than the .doc file gets converted properly to binary array that I can 
store to the database field of type image. But incase of .doc file, I have received 
error, which I have described below: 
 <o:p></o:p> 
****************Code to upload file(ABC.doc) and to store it into 
binaryarrAttachContent, which is an array of byte, runs on client web server as an 
asp.net page*************<o:p></o:p> 
  
 If Not fileAttach.PostedFile Is Nothing And fileAttach.PostedFile.ContentLength > 0 
Then 
 <o:p></o:p> 
            fileAttach.PostedFile.SaveAs(Server.MapPath(".") + "\" + 
Path.GetFileName(fileAttach.PostedFile.FileName))<o:p></o:p> 
            Dim objFileStream As New FileStream(Server.MapPath(".") + "\" + 
Path.GetFileName(fileAttach.PostedFile.FileName), FileMode.Open)<o:p></o:p> 
            Dim objBinary As New BinaryReader(objFileStream)<o:p></o:p> 
 <o:p></o:p> 
            binaryarrAttachContent = 
objBinary.ReadBytes(fileAttach.PostedFile.ContentLength)<o:p></o:p> 
            objFileStream.Close()<o:p></o:p> 
            objBinary.Close()<o:p></o:p> 
            File.Delete(Server.MapPath(".") + "\" + 
Path.GetFileName(fileAttach.PostedFile.FileName))<o:p></o:p> 
End If<o:p></o:p> 
***************************************************************************<o:p></o:p> 
*********************************************************************************************
 <o:p></o:p> 
'*Storing binaryarrAttachContent content (passed as parameter to web service from the 
above mentioned asp.net page) to the database(sqlserver2000). The code runs inside a 
web method in vb.net web service(FrontDesk.asmx)**** 
**********************************************************************************************<o:p></o:p>
 
Dim drNew As SqlDataReader<o:p></o:p> 
Dim objSqlNewCon As New 
SqlConnection(Configuration.ConfigurationSettings.AppSettings("strDB"))<o:p></o:p> 
 <o:p></o:p> 
 <o:p></o:p> 
objSqlNewCon.Open()<o:p></o:p> 
objComItem.CommandText = "MDTS_UPDATE_ITEM"<o:p></o:p> 
objComItem.CommandType = CommandType.StoredProcedure<o:p></o:p> 
objComItem.Parameters.Add("@CAMP_ID", decCamp_Id)<o:p></o:p> 
objComItem.Parameters.Add("@ITEM_ID", decItemID)<o:p></o:p> 
objComItem.Parameters.Add("@ITEM_NAME", strAttachFileName)<o:p></o:p> 
objComItem.Parameters.Add("@ITEM_CONTENT", binaryarrAttachContent) [EMAIL PROTECTED] 
is of type image(in sqlserver2000)<o:p></o:p> 
drNew = objComItem.ExecuteReader<o:p></o:p> 
objSqlNewCon.Close()<o:p></o:p> 
        
'**********************************************************************<o:p></o:p> 
I got the following error  <o:p></o:p> 
 <o:p></o:p> System.Web.Services.Protocols.SoapException: Server was unable to process 
request. ---> System.Data.SqlClient.SqlException: A severe error occurred on the 
current command. The results, if any, should be discarded. at 
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, 
RunBehavior runBehavior, Boolean returnStream) at 
System.Data.SqlClient.SqlCommand.ExecuteReader() at 
FRONT_DESK.clsViewCampaignOrder.strUpdateCampaignOrder(String[] strarrCampaign, 
Decimal decCamp_Id, String strURL, Byte[] binaryarrAttachContent, String 
strAttachFileName) in D:\MDTS\FrontDesk\clsViewCampaignOrder.vb:line 255 at 
FRONT_DESK.FrontDesk.strUpdateCampaignOrder(String[] strarrCampaign, Decimal 
decCamp_Id, String strURL, Byte[] binaryarrAttachContent, String strAttachFileName) in 
D:\MDTS\FrontDesk\FrontDesk.asmx.vb:line 234 --- End of inner exception stack trace 
--- <o:p></o:p> 
  
  
Pls help . 
Thanks in advance 
  
Suman Mukherjee <o:p></o:p>

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to