在Gridview中绑定图像 [英] Binding Image In Gridview

查看:58
本文介绍了在Gridview中绑定图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

在运行以下代码时,在

Hello

While runing the below code , im getting the issue as "ORA-00936: missing expression" on the line

Dim dReader As OracleDataReader = objOracleCommand.ExecuteReader()




我的代码





My Code


Dim objOracleConnection As OracleConnection
        objOracleConnection = New OracleConnection(ConfigurationManager.AppSettings("ConnectionString"))
        Dim objOracleCommand As New OracleCommand
        objOracleCommand.CommandText = "Select * from Photo where PHOTOID =@PHOTOID"
        objOracleCommand.CommandType = System.Data.CommandType.Text
        objOracleCommand.Connection = objOracleConnection
        Dim ImageID As New OracleParameter("@PHOTOID", OracleType.Number)
        ImageID.Value = context.Request.QueryString("PHOTOID")
        objOracleCommand.Parameters.Add(ImageID)
        objOracleConnection.Open()
        Dim dReader As OracleDataReader = objOracleCommand.ExecuteReader()
        dReader.Read()
        context.Response.BinaryWrite(DirectCast(dReader("BLOB"), Byte()))
        dReader.Close()
        objOracleConnection.Close()

推荐答案

@PhotoID参数为null,这将导致查询
The @PhotoID paramter is null which makes the query
Select * from Photo where PHOTOID =


这是Oracle中的语法错误.


which is a syntax error in Oracle.


您的代码假定您的Request字符串中始终存在PHOTOID的值.根本不是这种情况,它会破坏您所描述的代码.

尝试使用它们之前,请始终检查用户提供的值的存在性和正常性.
Your code is assuming that there will always be a value for PHOTOID in your Request string. This is simply not the case and will break your code as you''ve described.

Always check for the existance and normality of your user-supplied values before you try to use them.


这篇关于在Gridview中绑定图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆