I'm trying to do, an order and some orderline. Imagine that the user come and select several item from the shop then when he click on the checkout, the reference number in the order is send back to the several item in the orderline table. How would i insert that please??
Dim sql3 As String = "INSERT INTO OrderLine(ReferenceNumber) VALUES (@reference)" Dim ss As String = "False" Dim sql4 As String = "SELECT ReferenceNumber From [Order] where CustomerID = @username and Process= @Process" Dim sql5 As String = "Select CustomerID From Customer where Username =@username" Dim cmd3 As New SqlCommand(sql3, conss) Dim cmd4 As New SqlCommand(sql4, conss) Dim cmd5 As New SqlCommand(sql5, conss) cmd5.Parameters.AddWithValue("@username", Session("user")) Dim user As Integer = Convert.ToInt32(cmd5.ExecuteScalar().ToString()) cmd4.Parameters.AddWithValue("@username", user) cmd4.Parameters.AddWithValue("@Process", "False") Dim temp2 As Integer = 0 If (Not cmd4.ExecuteScalar().Equals(DBNull.Value)) Then temp2 = Convert.ToInt32(cmd4.ExecuteScalar.ToString()) Else temp2 = 0 End If temp2 = MsgBox(temp2.ToString) cmd3.Parameters.AddWithValue("@reference", temp2) cmd.ExecuteNonQuery()
but i realise that the executescalar take only one value, image if the user has done many order, the executescalar will take only the first one. have u any other idea how to make? dont forget that i'm using a login and that i use the login to get the customer id and store :)