Question : asp.net mssql. I have another sql connection problem trying to convert to sql.data.client

But now find I have another problem with this insert statement that follows the previous problem that was resolved .

I get this error for the insert statement that is at the end of the proc.

Compiler Error Message: BC30456: 'Command' is not a member of 'System.EventArgs'.

Source Error:

 -------------------------------

Line 146:        Me.ClientScript.RegisterStartupScript(Me.GetType(), "btnSaveImageSet1_Click", "alert(""" + Me.ILoad_MultipleImages1.Values.Count.ToString() + " image(s) saved..."");", True)
Line 147:
Line 148:        Using command1 As SqlCommand = DirectCast(e.Command.Connection.CreateCommand(), SqlCommand)
Line 149:            command1.CommandType = CommandType.Text
Line 150:            command1.CommandText = "INSERT INTO [CustomerImages] ([UserId],[EquipmentID], [Title], [ImageData], [MIMEType],[ImageId]) SELECT DISTINCT Equipment.[UserId], Equipment.[EquipmentID],[Example_E_204__Records].[Title],[ImageBytes],[MIMEType],[ImageId] FROM Equipment, [Radactive_ILoad_Images], Example_E_204__Records WHERE Equipment.ID = (SELECT MAX(Equipment.ID) FROM Equipment) AND [ConfigurationInternalCode] = 'Ex_E_204_ILoad1' AND ResizeInternalCode = 'Thumb1' AND ImageId = (SELECT MAX(ImageId) FROM Radactive_ILoad_Images) AND [Example_E_204__Records].[id] = (SELECT MAX(Id) FROM Example_E_204__Records)"
 
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
Protected Sub btnSaveImageSet1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        ' Store the fields into the WebImage.Tag property
        Me.ILoad_MultipleImages1.SaveFieldValuesIntoWebImageTags()

        '----------------------save images to database
        ' Save values to DB

        Dim imageId As String = MyDemoImageId
        Using connection As SqlConnection = Director.GetNewOpenDbConnection()
            'Using connection As OleDbConnection = Director.GetNewOpenDbConnection()
            'ILoadASCX.MultipleImages.ILoad_MultipleImages_Helper.SaveValuesToDB(Me.ILoad_MultipleImages1.Values, connection, Me.ILoad_MultipleImages1.ILoad.Configuration.InternalCode, imageId)
            Me.ILoad_MultipleImages1.SaveValuesToDB(connection, imageId)
        End Using

        Me.ClientScript.RegisterStartupScript(Me.GetType(), "btnSaveImageSet1_Click", "alert(""" + Me.ILoad_MultipleImages1.Values.Count.ToString() + " image(s) saved..."");", True)

        Using command1 As SqlCommand = DirectCast(e.Command.Connection.CreateCommand(), SqlCommand)
            command1.CommandType = CommandType.Text
            command1.CommandText = "INSERT INTO [CustomerImages] ([UserId],[EquipmentID], [Title], [ImageData], [MIMEType],[ImageId]) SELECT DISTINCT Equipment.[UserId], Equipment.[EquipmentID],[Example_E_204__Records].[Title],[ImageBytes],[MIMEType],[ImageId] FROM Equipment, [Radactive_ILoad_Images], Example_E_204__Records WHERE Equipment.ID = (SELECT MAX(Equipment.ID) FROM Equipment) AND [ConfigurationInternalCode] = 'Ex_E_204_ILoad1' AND ResizeInternalCode = 'Thumb1' AND ImageId = (SELECT MAX(ImageId) FROM Radactive_ILoad_Images) AND [Example_E_204__Records].[id] = (SELECT MAX(Id) FROM Example_E_204__Records)"
            command1.ExecuteNonQuery()
        End Using

    End Sub

Answer : asp.net mssql. I have another sql connection problem trying to convert to sql.data.client

Thats certainly an improvement... now you just need to step through the code and find which object is null and work out why.

Actually I think I see the problem, you appear to be using a mix of OleDb and Sql - you've created an OleDb connection and then asked it to give you a command - which it will, an OleDbCommand - but then you're tried to cast it to an SqlCommand which won't work.

You need to decide whether you're working on OleDb or native Sql Server and then ensure your code is consistent with your choice.
Random Solutions  
 
programming4us programming4us