C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Interview   Jobs   Projects   Offshore Development    
Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing | Talk to Us |



My Profile

Gifts

Active Members
TodayLast 7 Days more...







plz help me


Posted Date: 31 Mar 2008      Total Responses: 1

Posted By: payal       Member Level: Gold     Points: 2


Hi,
I wrote the following code to retrieve an image from sql server. I am getting the output if i was not putting the where condition. But i want to pass the where condition as i require a specific image.

<HTML>
<HEAD>
<title>Retrieving Image from the Sql Server</title>
<script runat=server>
Public Sub Addperson(ByVal sender As Object, ByVal e As EventArgs)
' Create Instance of Connection and Command Object
Dim myConnection As New SqlConnection(ConfigurationSettings.AppSettings("Constring"))
Dim myCommand As New SqlCommand("Select * from image where invoice_no =' Form1.txt_no.text '", myConnection)
Try

myConnection.Open()
Dim myDataReader As SqlDataReader
myDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
Do While (myDataReader.Read())
Response.ContentType = myDataReader.Item("Image_Type")
Response.BinaryWrite(myDataReader.Item("Image"))
Loop
myConnection.Close()
Response.Write("Image successfully retrieved!")
Catch SQLexc As SqlException
Response.Write("Read Failed : " & SQLexc.ToString())
End Try
End Sub


</script>
</HEAD>

But i am getting the following error

Read Failed : System.Data.SqlClient.SqlException: Error converting data type varchar to bigint. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlDataReader.HasMoreRows() at System.Data.SqlClient.SqlDataReader.ReadInternal(Boolean setTimeout) at System.Data.SqlClient.SqlDataReader.Read() at ASP.retrieve_aspx.Addperson(Object sender, EventArgs e) in D:\FILE SAVING IN DATBASE\Retrieve.aspx:line 19

Plz help me





Responses

Author: Praveen Kumar    31 Mar 2008Member Level: GoldRating:     Points: 2
I think your invoice_no is asking for integer value and you are giving varchar in textbox. please fix it first


Post Reply
You must Sign In to post a response.
Next : i have 3 point on canvas ,i want to remove it or invisible
Previous : error while accessing MSAccess database
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design   Scripts

conference call

Contact Us    Privacy Policy    Terms Of Use