问题描述
我在我的网站上使用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">
<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="<%# Eval("SRNO") %>"></asp:label>
</edititemtemplate>
<insertitemtemplate>
<asp:textbox id="TextBox2" runat="server" readonly="True"></asp:textbox>
</insertitemtemplate>
<itemtemplate>
<asp:label id="Label2" runat="server" text="<%# Bind("SRNO") %>"></asp:label>
</itemtemplate>
</asp:templatefield>
<asp:templatefield headertext="CERTPURPOSE" sortexpression="CERTPURPOSE">
<edititemtemplate>
<asp:textbox id="TextBox1" runat="server" text="<%# Bind("CERTPURPOSE") %>">
TextMode="MultiLine" Width="350px" Height="66px"></asp:textbox>
</edititemtemplate>
<insertitemtemplate>
<asp:textbox id="TextBox1" runat="server" text="<%# Bind("CERTPURPOSE") %>">
Height="66px" TextMode="MultiLine" Width="350px"></asp:textbox>
</insertitemtemplate>
<itemtemplate>
<asp:label id="Label1" runat="server" text="<%# Bind("CERTPURPOSE") %>"></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="<%$ ConnectionStrings:ConnectionString1 %>"
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="<%$ ConnectionStrings:ConnectionString1.ProviderName %>"
SelectCommand="SELECT SRNO, CERTPURPOSE FROM PURPOSE_MASTER"
UpdateCommand="UPDATE PURPOSE_MASTER SET SRNO =, CERTPURPOSE = ''">
</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时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!