Inserting into a Database from a Dataset - Formula Help VB.Net Easy Question
Posted on 2005-03-30
I have an easy one.
I have a web method set-up that accepts a dataset from client.
Dim myDA1 As SqlDataAdapter = New SqlDataAdapter
myDA1.InsertCommand = New SqlCommand("Insert into Rec_Orders (order_Number, qty, cost, value) Values (@order_Number, @qty, @cost, (@cost * @qty))", myConn)
myDA1.InsertCommand.Parameters.Add("@order_Number", SqlDbType.Int, 4, "order_Number")
myDA1.InsertCommand.Parameters.Add("@qty", SqlDbType.Int, 9, "qty")
myDA1.InsertCommand.Parameters.Add("@cost", SqlDbType.Int, 9, "cost")
'right here ...I am talking about
myDA1.InsertCommand.Parameters.Add("(@cost * @qty)", SqlDbType.Int, 9, "value")
Dim param As SqlParameter = myDA1.InsertCommand.Parameters.Add("@Identity", SqlDbType.Int, 0, "id")
param.Direction = ParameterDirection.Output
My question is I am inserting into a table that has 4 fields.
The Value field is a field that is populated by qty multipled by cost...ie (@qty * @cost)
Do I have this done right in my Insert Statement and also have I got it right in the section where I declare my parameters.
Any insight or help would be great.