Help: Input string not in correct format

B

blackg

Input string not in correct format
--------------------------------------------------------------------------------
I am trying to view a picture from a table. I am getting this error
Input string not in the correct format.
Input string was not in a correct format.

Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.FormatException: Input string was not in a
correct format.

Source Error:


Line 45: cmdGetFile.Parameters("@AttachmentID").Value =
Request("AttachmentID").ToString
Line 46: dbconn.Open()
Line 47: dr = cmdGetFile.ExecuteReader
Line 48: If dr.Read Then
Line 49: Response.ContentType = dr("ContentType").ToString



Source File: d:\inetpub\wwwroot\viewpictures\ViewAttachment.aspx.vb
Line: 47

Stack Trace:


[FormatException: Input string was not in a correct format.]
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
System.Data.SqlClient.SqlCommand.ExecuteReader()
Computers_Net.ViewAttachment.Page_Load(Object sender, EventArgs e)
in d:\inetpub\wwwroot\viewpicturest\ViewAttachment.aspx.vb:47
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()

Any help will be appreciated
Thanks in advance
 
K

Karl Seguin

The error is likely with your commandText which you didn't show up (the
actual SELECT)

Alternatively, Request("AttachmentId") might be null...but I doubt that...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)


blackg said:
Input string not in correct format
-------------------------------------------------------------------------- ------
I am trying to view a picture from a table. I am getting this error
Input string not in the correct format.
Input string was not in a correct format.

Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.FormatException: Input string was not in a
correct format.

Source Error:


Line 45: cmdGetFile.Parameters("@AttachmentID").Value =
Request("AttachmentID").ToString
Line 46: dbconn.Open()
Line 47: dr = cmdGetFile.ExecuteReader
Line 48: If dr.Read Then
Line 49: Response.ContentType = dr("ContentType").ToString



Source File: d:\inetpub\wwwroot\viewpictures\ViewAttachment.aspx.vb
Line: 47

Stack Trace:


[FormatException: Input string was not in a correct format.]
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
System.Data.SqlClient.SqlCommand.ExecuteReader()
Computers_Net.ViewAttachment.Page_Load(Object sender, EventArgs e)
in d:\inetpub\wwwroot\viewpicturest\ViewAttachment.aspx.vb:47
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()

Any help will be appreciated
Thanks in advance
 
B

blackg

Thank you Karl for your response:
Here is my SqlCommandText:

SELECT FileSize, FileName, FileData, ContentType
FROM tblAttachments WHERE (AttachmentID = @AttachmentID)

Thanks in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top