Question : asp.net How can I include an insert sql statement in the codebehind of anaspx page.

The procedure insert an image into the database, I would also like to insert it into another
area table of the db
---------------------------------------------------------------------------------------
 Protected Sub SqlDataSource1_Inserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs)
        ' Save the picture into database

        ' Get the new recordId
        Dim id As Integer
        Using command As SqlCommand = DirectCast(e.Command.Connection.CreateCommand(), SqlCommand)
            command.CommandType = CommandType.Text
            command.CommandText = "SELECT @@IDENTITY"

            id = Convert.ToInt32(command.ExecuteScalar())
        End Using

        ' Get the image id
        Dim imageId As String = id.ToString()

        ' Get the ILoad Control
        Dim picture1 As ILoad = DirectCast(Me.FormView1.Row.FindControl("picture1"), ILoad)

        ' Update image files in database
        'WebImage.SynchronizeCustomStorage(picture1.Value, Director.Ex_E_204_ILoad1_InternalCode, imageId)
        picture1.SynchronizeCustomStorage(imageId)

'---------------------------------------------------------------------------------------------
   Can I insert the code here and what is the correct way if it can be done...to insert and run the code in the code block.
'--------------------------------------------------------------------------------------------

    End Sub
1:
2:
3:
4:
5:
6:
INSERT INTO [CustomerImages] ([ImageID],[EquipmentID],  [ImageData], MIMEType)
SELECT DISTINCT Equipment.[UserId], Equipment.[EquipmentID], [ImageBytes],[MIMEType]
FROM Equipment, [Radactive_ILoad_Images], [Example_E_204__Records] 
WHERE Equipment.ID = (SELECT MAX(ID) FROM Equipment)
 AND [ConfigurationInternalCode] = 'Ex_E_204_ILoad1'
 AND ResizeInternalCode = 'Thumb1' AND ImageId = (SELECT MAX(ImageId) FROM Radactive_ILoad_Images)

Answer : asp.net How can I include an insert sql statement in the codebehind of anaspx page.

If the object are so big, I'd create these objects in the heap (with new operator) and store the pointers in the map. I'd make a class that will manage this store and will have a member of this map. This class may have a Clear() method that will delete all MyLargeObj's. This Clear should be called from the class destructor. This way will allow to hide the implementation of the MyLargeObj even, if it is needed.

Random Solutions  
 
programming4us programming4us