2

如果我为 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>
4

1 回答 1

0

Thanks for the help Garrison!

I changed @JOB_ID to :JOB_ID in the deletecommand, which was the syntax in the link you posted, and it worked. No idea why as almost all of the examples out there use @ for a parameter, but thanks again.

于 2013-08-29T21:12:45.867 回答