【发布时间】:2016-09-08 19:53:42
【问题描述】:
我正在使用StringBuilder 在asp.net 中使用多个查询。但我收到错误
ORA-00936:缺少表达式
以下是我的查询。
StringBuilder sb = new StringBuilder();
if (ddlProject.SelectedValue != "0" && ddlBuilding.SelectedValue != "0")
{
sb.Append("insert into xxacl_pN_LEASES_ALL_h select sysdate,* from xxacl_pN_LEASES_ALL");
sb.Append(";");
sb.Append("update xxacl_pN_LEASES_ALL set ASSIGNED_TO = '" + ddlSalesUser.SelectedValue + "'");
sb.Append(";");
}
if (ddlProject.SelectedValue != "0" && ddlBuilding.SelectedValue == "0")
{
sb.Append("insert into xxacl_pN_LEASES_ALL_h select sysdate,* from xxacl_pN_LEASES_ALL");
sb.Append(";");
sb.Append("update xxacl_pN_LEASES_ALL set ASSIGNED_TO = '" + ddlSalesUser.SelectedValue + "'");
sb.Append(";");
}
OracleConnection ObjPriCon = new OracleConnection(System.Configuration.ConfigurationManager.ConnectionStrings["OracleConn"].ToString());
OracleCommand cmd1 = new OracleCommand();
string allQueries = sb.ToString();
cmd1.CommandText = allQueries;
cmd1.Connection = ObjPriCon;
ObjPriCon.Open();
cmd1.ExecuteNonQuery(); // here is the error caused
ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Record updated successfully');window.location ='FrmHoldingCoordinateUpdate.aspx?TranType=FM&PView=N&Mode=A&Redirect=oracle&Key=0&Redirect=" + Request.QueryString["Redirect"] + "&userid=" + Request.QueryString["userid"].ToString() + "';", true);
另外,allQueries 给出的结果为
insert into xxacl_pN_LEASES_ALL_h select getdate(),* from xxacl_pN_LEASES_ALL;update xxacl_pN_LEASES_ALL set ASSIGNED_TO = '5681';
【问题讨论】:
-
Oracle 是否支持 'GETDATE()'?
-
@ThomasSchremser:不,对不起我的错误,我会改变它。是这个错误吗?
-
插入xxacl_pN_LEASES_ALL_h后是否应该有分号
-
@Mysterio11: 你能给出你所说的语法吗?
-
我错了。但你到底想做什么?
标签: c# asp.net oracle stringbuilder