本文介绍了Oracle查询DetailsView时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我在我的网站上使用detailsView.我正在使用oracle 10g. OleDB连接.

我的代码是:

Hi,
I am using detailsView in my website. I am using oracle 10g. OleDB Connection.

My Code is:

<asp:detailsview id="DetailsView1" runat="server" allowpaging="True" xmlns:asp="#unknown">
        AutoGenerateDeleteButton="True" AutoGenerateEditButton="True" 
        AutoGenerateInsertButton="True" AutoGenerateRows="False" DataKeyNames="SRNO" 
        DataSourceID="SqlDataSource1" Height="50px" Width="680px" 
        BackColor="White" BorderColor="#CC9966" BorderStyle="None" BorderWidth="1px" 
        CellPadding="4"&gt;
        <footerstyle backcolor="#FFFFCC" forecolor="#330099" />
        <rowstyle backcolor="White" forecolor="#330099" />
        <pagerstyle backcolor="#FFFFCC" forecolor="#330099" horizontalalign="Center" />
        <fields>
            <asp:templatefield headertext="SRNO" sortexpression="SRNO">
                <edititemtemplate>
                    <asp:label id="Label1" runat="server" text="&lt;%# Eval("SRNO") %&gt;"></asp:label>
                </edititemtemplate>
                <insertitemtemplate>
                    <asp:textbox id="TextBox2" runat="server" readonly="True"></asp:textbox>
                </insertitemtemplate>
                <itemtemplate>
                    <asp:label id="Label2" runat="server" text="&lt;%# Bind("SRNO") %&gt;"></asp:label>
                </itemtemplate>
            </asp:templatefield>
            <asp:templatefield headertext="CERTPURPOSE" sortexpression="CERTPURPOSE">
                <edititemtemplate>
                    <asp:textbox id="TextBox1" runat="server" text="&lt;%# Bind("CERTPURPOSE") %&gt;">
                        TextMode="MultiLine" Width="350px" Height="66px"&gt;</asp:textbox>
                </edititemtemplate>
                <insertitemtemplate>
                    <asp:textbox id="TextBox1" runat="server" text="&lt;%# Bind("CERTPURPOSE") %&gt;">
                        Height="66px" TextMode="MultiLine" Width="350px"&gt;</asp:textbox>
                </insertitemtemplate>
                <itemtemplate>
                    <asp:label id="Label1" runat="server" text="&lt;%# Bind("CERTPURPOSE") %&gt;"></asp:label>
                </itemtemplate>
            </asp:templatefield>
        </fields>
        <headerstyle backcolor="#990000" font-bold="True" forecolor="#FFFFCC" />
        <editrowstyle backcolor="#FFCC66" font-bold="True" forecolor="#663399" />
    </asp:detailsview>
    <asp:sqldatasource id="SqlDataSource1" runat="server" xmlns:asp="#unknown">
        ConnectionString="&lt;%$ ConnectionStrings:ConnectionString1 %&gt;" 
        DeleteCommand="DELETE FROM PURPOSE_MASTER" 
        InsertCommand="INSERT INTO PURPOSE_MASTER(SRNO, CERTPURPOSE, EX1, EX2) VALUES (0,' <b>// HERE i want to point Specific Field to insert into Database</b> ', 0, '--')" 
        ProviderName="&lt;%$ ConnectionStrings:ConnectionString1.ProviderName %&gt;" 
        SelectCommand="SELECT SRNO, CERTPURPOSE FROM PURPOSE_MASTER" 
        UpdateCommand="UPDATE PURPOSE_MASTER SET SRNO =, CERTPURPOSE = ''"&gt;
    </asp:sqldatasource>


我已经手动创建了这些语句.这些都是数据绑定.
实际上,方括号会在Oracle Query中引发错误.

现在,我想在插入数据库时​​指向特定的textBox.
我已经使用了"@"符号,但是会引发运行时错误.

请帮忙!


I have created these statement manually. These all are Databounds.
Actually Square bracket raises error in Oracle Query.

Now I want to point specific textBox while inserting in database.
I have used '' @ '' symbol, but it raises runtime Error.

Please Help!

推荐答案



我已经手动创建了这些语句.这些都是数据绑定.
实际上,方括号会在Oracle Query中引发错误.

现在,我想在插入数据库时​​指向特定的textBox.
我已经使用了"@"符号,但是会引发运行时错误.

请帮忙!


I have created these statement manually. These all are Databounds.
Actually Square bracket raises error in Oracle Query.

Now I want to point specific textBox while inserting in database.
I have used '' @ '' symbol, but it raises runtime Error.

Please Help!


protected void SqlDataSource1_Inserting(object sender, ObjectDataSourceMethodEventArgs e)
{
  TextBox myTextbox = (TextBox)DetailsView1.FindControl("TextBox1");
  string MySQL = ="INSERT INTO PURPOSE_MASTER(SRNO, CERTPURPOSE, EX1, EX2) VALUES (0,''"
  MySQL += myTextbox.Text;
  MySQL += "'', 0, ''--'')";
  SqlDataSource1.InsertCommand = MySQL;
}


这篇关于Oracle查询DetailsView时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 03:39