אנשים אוהבים לראות קוד...
או קי נראה קוד אם זה יעזור..
ממש בקיצור..
Dim myConnection As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("DSN1")) Dim myCommand As SqlCommand = New SqlCommand("ShoppingCartUpdateItem", myConnection) ' Mark the Command as a SPROC myCommand.CommandType = CommandType.StoredProcedure ' Add Parameters to SPROC Dim parameterProductID As SqlParameter = New SqlParameter("@ProductID", SqlDbType.Int, 4) parameterProductID.Value = productID myCommand.Parameters.Add(parameterProductID) Dim parameterCartID As SqlParameter = New SqlParameter("@CartID", SqlDbType.NVarChar, 50) parameterCartID.Value = cartID myCommand.Parameters.Add(parameterCartID) Dim parameterQuantity As SqlParameter = New SqlParameter("@Quantity", SqlDbType.TinyInt, 1) parameterQuantity.Value = quantity myCommand.Parameters.Add(parameterQuantity) ' Open the connection and execute the Command myConnection.Open() myCommand.ExecuteNonQuery() myConnection.Close()
עדכון כמות המוצר עכשיו ב USER CONTROL אחר אני מבקש את הסכום הכללי של הקניה... הנה הקוד
Dim myConnection As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("DSN1")) Dim myCommand As SqlCommand = New SqlCommand("ShoppingCartTotal", myConnection) ' Mark the Command as a SPROC myCommand.CommandType = CommandType.StoredProcedure ' Add Parameters to SPROC Dim parameterCartID As SqlParameter = New SqlParameter("@cartID", SqlDbType.NVarChar, 50) parameterCartID.Value = cartID myCommand.Parameters.Add(parameterCartID) Dim parameterTariffID As SqlParameter = New SqlParameter("@tariffID", SqlDbType.SmallInt, 50) parameterTariffID.Value = ConfigurationSettings.AppSettings("TariffID") myCommand.Parameters.Add(parameterTariffID) Dim parameterTotalCost As SqlParameter = New SqlParameter("@totalCost", SqlDbType.Money, 8) parameterTotalCost.Direction = ParameterDirection.Output myCommand.Parameters.Add(parameterTotalCost) ' Open the connection and execute the Command myConnection.Open() myCommand.ExecuteNonQuery() myConnection.Close() ' Return the Total If parameterTotalCost.Value.ToString() <> "" Then Return CType(parameterTotalCost.Value, Decimal) Else Return 0 End If
נפלא אה...