Oracle查询DetailsView时出错 [英] Error in Oracle query for detailsview

查看:79
本文介绍了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!

推荐答案

ConnectionStrings:ConnectionString1%& gt; DeleteCommand =从PURPOSE_MASTER中删除" InsertCommand ="INSERT INTO PURPOSE_MASTER(SRNO,CERTPURPOSE,EX1,EX2)值(0,' b > //在这里,我想指出要插入到数据库中的特定字段< /b > ',0,'-')" ProviderName =& 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 =选择SRNO,从PURPOSE_MASTER转换为特定字符" UpdateCommand ="UPDATE PURPOSE_MASTER SET SRNO =,CERTPURPOSE =''"& gt; < /asp:sqldatasource >
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!


有几种方法可以做到这一点.一种方法是在SqlDataSource1_Inserting事件中使用代码隐藏.在事件代码中,可以将SqlDataSource1.InsertCommand属性字符串设置为所需的任何字符串.这样的事情可能会做到.


There are several ways to do this. One way is to use code-behind in the SqlDataSource1_Inserting event. In the event code you can set the SqlDataSource1.InsertCommand property string to whatever you need. Something like this might do it.


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时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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