469,609 Members | 2,231 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,609 developers. It's quick & easy.

Help: Input string not in correct format

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.asp x.vb
Line: 47

Stack Trace:
[FormatException: Input string was not in a correct format.]
System.Data.SqlClient.SqlCommand.ExecuteReader(Com mandBehavior
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.as px.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
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 19 '05 #1
5 2334
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" <ea*******@hotmail-dot-com.no-spam.invalid> wrote in message
news:42**********@127.0.0.1...
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.asp x.vb
Line: 47

Stack Trace:
[FormatException: Input string was not in a correct format.]
System.Data.SqlClient.SqlCommand.ExecuteReader(Com mandBehavior
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.as px.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
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Nov 19 '05 #2
Thank you Karl for your response:
Here is my SqlCommandText:

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

Thanks in advance
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 19 '05 #3
Doesn't seem to be anything wrong with that...

I'd go with my other guess than, Request("AttachmentId") is null or some
invalid value...you should take a quick look at it to see

Also, i suspect that the parameter is being loaded something like:

cmdGetFile.Parameters.Add("@AttachmentID", SqlDbType.Int)

or something?

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" <ea*******@hotmail-dot-com.no-spam.invalid> wrote in message
news:42**********@127.0.0.1...
Thank you Karl for your response:
Here is my SqlCommandText:

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

Thanks in advance
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Nov 19 '05 #4
So how should the code look like?
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 19 '05 #5
What code?

On 10 Mar 2005 15:36:45 -0600,
ea*******@hotmail-dot-com.no-spam.invalid (blackg) wrote:
So how should the code look like?
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com


--
Scott
http://www.OdeToCode.com/blogs/scott/
Nov 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by lianfe_ravago | last post: by
22 posts views Thread by Amali | last post: by
7 posts views Thread by Mirnes | last post: by
reply views Thread by Solution2021 | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.