Help: Input string not in correct format

  • Thread starter Thread starter blackg
  • Start date Start date
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
 
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
 
Thank you Karl for your response:
Here is my SqlCommandText:

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

Thanks in advance
 
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 said:
Thank you Karl for your response:
Here is my SqlCommandText:

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

Thanks in advance
 
Back
Top