如果我对deletecommand使用硬编码值(其中JOB_ID = 123),它可以工作,但是当我尝试使用参数时,我收到此错误:
Oracle.DataAccess.Client.OracleException:ORA-00936:缺少表达式。
JOB_ID是数据库中的varchar2字段。任何帮助都会很棒。
<asp:GridView ID="GridView1" DataSourceID="SqlDataSource1"
runat="server" DataKeyNames="JOB_ID" AutoGenerateColumns="false" ShowHeader="true">
<columns>
<asp:boundfield datafield="JOB_ID" headertext="Job ID"/>
<asp:boundfield datafield="JOB_DATE_CLOSED" headertext="Posting Closes On"/>
<asp:boundfield datafield="JOB_DESC" headertext="Job Description"/>
<asp:TemplateField>
<ItemTemplate>
<asp:Button id="DeleteButton" runat="server" text="Delete"
CommandName="Delete" OnClientClick="return confirm('Delete this Record?');" >
</asp:Button>
</ItemTemplate>
</asp:TemplateField>
</columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:OracleInternet %>"
ProviderName="<%$ ConnectionStrings:OracleInternet.ProviderName %>"
SelectCommand="SELECT JOB_ID, JOB_DATE_CLOSED, JOB_DESC FROM OWNER.JOB_POSTING"
DeleteCommand="DELETE FROM OWNER.JOB_POSTING WHERE JOB_ID = @JOB_ID" >
<DeleteParameters>
<asp:Parameter Name="JOB_ID" Type="String" />
</DeleteParameters>
</asp:SqlDataSource>
答案 0 :(得分:0)
感谢Garrison的帮助!
我在删除命令中将@JOB_ID更改为:JOB_ID,这是您发布的链接中的语法,并且它有效。不知道为什么几乎所有的例子都使用@作为参数,但再次感谢。