如何从VB.net中的两个不同表中减去两列?

时间:2016-09-05 13:12:59

标签: sql vb.net

我刚刚开始使用VB.net并且知道我还是新手,我很难从两个不同的表中减去名为Quantity and Stocks的列(1.Sales和2.AddItem)我想要的每当我按下名为"购买" ,它会减去数量"数量"在" Stocks"的数量。可能吗?感谢。

    Dim connectString As String
    Dim conn As SqlConnection
    Dim adapter As New SqlDataAdapter
    Dim sql As String
    connectString = "Data Source=LENOVO\MYSQL;Integrated Security=True;database = CellSalesandInventory"
    conn = New SqlConnection(connectString)
    sql = "insert into Sales (NameofUser,ProductCode,Brand,Model,NameofCustomer,Age,Sex,Address,Date,Quantity,Warranty,Price) values ('" & TextBox10.Text & "','" & TextBox1.Text & "',
   '" & TextBox6.Text & "','" & TextBox11.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & ComboBox1.Text & "','" & TextBox4.Text & "',
   '" & TextBox5.Text & "','" & TextBox7.Text & "','" & TextBox8.Text & "','" & TextBox9.Text & "') "
    Try
        conn.Open()
        adapter.InsertCommand = New SqlCommand(sql, conn)
        adapter.InsertCommand.ExecuteNonQuery()
        MessageBox.Show("You just purchased a product!Thank You!")
    Catch ex As Exception
        MsgBox(ex.ToString)
End Sub

0 个答案:

没有答案