0

我正在尝试使用 asp.net 从表单中收集数据并将其插入到由多个表组成的 sql 视图中。但是一直显示错误,说“v_orderdetails 不可更新,因为修改会影响多个基表。” 谁能帮忙,下面是我的代码:

public partial class _Order : System.Web.UI.Page
{
    string myConnectionString;


    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
        }
    }

    protected void Orderbtn_Click(object sender, EventArgs e)
    {
        SqlConnection myConn = new SqlConnection();
        myConnectionString = "server=CSSQL; database=Oh31_PE; Trusted_Connection = true";
        myConn.ConnectionString = myConnectionString;

        string querystring1;
        querystring1 = "insert into v_orderdetails (dbo.t_order.OrderDate, dbo.t_product.Material, dbo.t_product.Description, dbo.t_orderdetails.Quantity) values ( '";
        querystring1 += od.Text + "','" + opname.Text + "','" + tom.Text + "','" + tod.Text + "','" + qq.Text + "')";

        SqlCommand dbcommand1 = new SqlCommand();
        dbcommand1.CommandText = querystring1;
        dbcommand1.Connection = myConn;
        myConn.Open();
        dbcommand1.ExecuteNonQuery();
        myConn.Close();

        {
            Response.Redirect("Order.aspx");
        }



    } // end Orderbtn_Click
}
4

0 回答 0