如果我使用硬編碼值DeleteCommand會(其中JOB_ID = 123),它的工作原理,但是當我嘗試使用參數我得到這個錯誤:刪除的GridView不工作
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>
這裏的示例對參數使用不同的查詢語法,它也使用'ControlParameter'而不是'Parameter'。我從來沒有親自做過這樣的事情,但也許這會幫助你。 https://forums.oracle.com/thread/622971?start=0&tstart=0 –
也許有需要鑄造? – andi