如何在asp.net中使用sqldatasource将oracle sequence nextval作为插入操作的参数传递 [英] how to pass oracle sequence nextval as a parameter for insert operation using sqldatasource in asp.net
问题描述
嗨....
有没有办法将oracle序列值作为参数传递给sqldatasource插入操作?或者有一些不同的方法呢?我在运行以下代码时遇到ora-01036错误非法值:
< asp:SqlDataSource ID = sqlcrud runat = server
ConnectionString = <%$ ConnectionStrings:testconn%>
InsertCommand = INSERT INTO PEOPLE ( EMP_ID , FNAME , GENDER , DEPT )VALUES(SEQ_PEOPLE.NEXTVAL,:FNAME, :GENDER,:DEPT)
ProviderName = <%$ ConnectionStrings:testconn.ProviderName%>
UpdateCommand = UPDATE PEOPLE SET FNAME =:FNAME, GENDER =:GENDER, DEPT =:DEPT WHERE EMP_ID =:EMP_ID >
代码隐藏文件:
受保护 void linkinsert_Click ( object sender,EventArgs e)
{
sqlcrud.InsertParameters [ FNAME]。DefaultValue =
((TextBox)GridView1.FooterRow.FindControl( txtinsertname))。文本;
sqlcrud.InsertParameters [ GENDER]。DefaultValue =
((DropDownList)GridView1.FooterRow.FindControl( dropgenderinsert))。SelectedValue;
sqlcrud.InsertParameters [ DEPT]。DefaultValue =
((TextBox)GridView1.FooterRow.FindControl( txtinsertdept))。文本;
sqlcrud.Insert();
}
虽然更新命令运行正常,但是插入命令会抛出错误..
我们将非常感谢任何帮助。
谢谢... !!
< blockquote> ConnectionStrings:testconn%>
InsertCommand = INSERT INTO PEOPLE ( EMP_ID < span class =code-string>, FNAME , GENDER , DEPT )VALUES(SEQ_PEOPLE.NEXTVAL,:FNAME,:GENDER,:DEPT)
ProviderName = <%
的ConnectionStrings:testconn.Prov iderName%>
UpdateCommand = UPDATE PEOPLE SET FNAME =:FNAME, GENDER =:GENDER, DEPT < span class =code-string> =:DEPT WHERE EMP_ID < span class =code-string> =:EMP_ID >
代码隐藏文件:
protected void linkinsert_Click( object sender,EventArgs e)
{
sqlcrud .InsertParameters [ FNAME]。DefaultValue =
((TextBox)GridView1.FooterRow.FindControl( txtinsertname))。文本;
sqlcrud.InsertParameters [ GENDER]。DefaultValue =
((DropDownList)GridView1.FooterRow.FindControl( dropgenderinsert))。SelectedValue;
sqlcrud.InsertParameters [ DEPT]。DefaultValue =
((TextBox)GridView1.FooterRow.FindControl( txtinsertdept))。文本;
sqlcrud.Insert();
}
虽然更新命令运行正常,但是插入命令会抛出错误..
任何帮助将不胜感激。
谢谢...... !!
它有效!! ....
< insertparameters>
<% - < asp:参数名= EMP_ID type = < span class =code-string> 十进制 xmlns:asp = < span class =code-string>#unknown /> - %>
< asp:parameter name = < span class =code-string> FNAME type = 字符串 xmlns:asp = #unknown / >
< asp:参数名= GENDER type = 字符串 xmlns:asp = #unknown />
< asp:parameter name = DEPT type = 字符串 xmlns:asp = #unknown />
< / insertparameters >
我评论了在...之前取消注释的EMP_ID参数:)
Hi....
Is there any way to pass oracle sequence value as a parameter in sqldatasource insert operation?? Or there is some different way to do so? I am having ora-01036 error illegal value while running the following code:
<asp:SqlDataSource ID="sqlcrud" runat="server"
ConnectionString="<%$ ConnectionStrings:testconn %>"
InsertCommand="INSERT INTO "PEOPLE" ("EMP_ID", "FNAME", "GENDER", "DEPT") VALUES (SEQ_PEOPLE.NEXTVAL, :FNAME, :GENDER, :DEPT)"
ProviderName="<%$ ConnectionStrings:testconn.ProviderName %>"
UpdateCommand="UPDATE "PEOPLE" SET "FNAME" = :FNAME, "GENDER" = :GENDER, "DEPT" = :DEPT WHERE "EMP_ID" = :EMP_ID">
code behind file:
protected void linkinsert_Click(object sender, EventArgs e)
{
sqlcrud.InsertParameters["FNAME"].DefaultValue =
((TextBox)GridView1.FooterRow.FindControl("txtinsertname")).Text;
sqlcrud.InsertParameters["GENDER"].DefaultValue =
((DropDownList)GridView1.FooterRow.FindControl("dropgenderinsert")).SelectedValue;
sqlcrud.InsertParameters["DEPT"].DefaultValue =
((TextBox)GridView1.FooterRow.FindControl("txtinsertdept")).Text;
sqlcrud.Insert();
}
though the update command runs good, insert command is throwing the error..
Any help will be greatly appreciated.
Thank you...!!
ConnectionStrings:testconn %>" InsertCommand="INSERT INTO "PEOPLE" ("EMP_ID", "FNAME", "GENDER", "DEPT") VALUES (SEQ_PEOPLE.NEXTVAL, :FNAME, :GENDER, :DEPT)" ProviderName="<%
ConnectionStrings:testconn.ProviderName %>" UpdateCommand="UPDATE "PEOPLE" SET "FNAME" = :FNAME, "GENDER" = :GENDER, "DEPT" = :DEPT WHERE "EMP_ID" = :EMP_ID">
code behind file:
protected void linkinsert_Click(object sender, EventArgs e) { sqlcrud.InsertParameters["FNAME"].DefaultValue = ((TextBox)GridView1.FooterRow.FindControl("txtinsertname")).Text; sqlcrud.InsertParameters["GENDER"].DefaultValue = ((DropDownList)GridView1.FooterRow.FindControl("dropgenderinsert")).SelectedValue; sqlcrud.InsertParameters["DEPT"].DefaultValue = ((TextBox)GridView1.FooterRow.FindControl("txtinsertdept")).Text; sqlcrud.Insert(); }
though the update command runs good, insert command is throwing the error..
Any help will be greatly appreciated.
Thank you...!!
it worked!!....
<insertparameters> <%--<asp:parameter name="EMP_ID" type="Decimal" xmlns:asp="#unknown" />--%> <asp:parameter name="FNAME" type="String" xmlns:asp="#unknown" /> <asp:parameter name="GENDER" type="String" xmlns:asp="#unknown" /> <asp:parameter name="DEPT" type="String" xmlns:asp="#unknown" /> </insertparameters>
I commented the EMP_ID parameter that was uncommented before... :)
这篇关于如何在asp.net中使用sqldatasource将oracle sequence nextval作为插入操作的参数传递的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!