Looks like I can't stop having problems with SQL haha
I'm trying to delete a value from a database using the following code, and I have no idea where it's going wrong. It gives the messageboxes saying the operation goes through ok, but doesn't actually delete the data. Here's my code :

Dim TuneTitle As String = TuneTitleBox.Text
        Dim FilePath As String = FilePathBox.Text
        Dim DataCommand As New SqlCeCommand
        Dim DeleteString As String = "DELETE FROM Music WHERE TuneTitle ='" & TuneTitle & "' AND Filepath ='" & FilePath & "'"

        MessageBox.Show(DeleteString)
        sqlcon.Open()
        DataCommand = sqlcon.CreateCommand
        DataCommand.CommandText = DeleteString
        'check both values entered
        If TuneTitle <> "" And FilePath <> "" Then
            Try
                DataCommand.ExecuteNonQuery()
                MessageBox.Show("'" & TuneTitle & "' was successfully removed from the database")

            Catch ex As Exception
                MessageBox.Show("Please ensure that the values you have used exist in the database")
            End Try



        Else : MessageBox.Show("Please enter both the Tune Title and File Path")
        End If
        sqlcon.Close()

Thanks

hii rmontgomery
write your code with the sql transaction. after deleting the data commit the transaction. then it will remove successfully try this. if thread is sole mark as a solve

hii rmontgomery
write your code with the sql transaction. after deleting the data commit the transaction. then it will remove successfully try this. if thread is sole mark as a solve

Heya, thanks for the reply. I've looked around for info on how to utilise transactions using SqlCe, but I can't find anything. I've tried using the same methods as would be used for a standard Sql transaction, but is doesn't recognise:

Dim Transaction as myConnection.BeginTransaction

Thanks again

for sql transaction first off all goto project solution -> right click-> add references-> then tick mark the sql transaction and .dll will be added
now at the top of import the syste. transaction class and then continue. with
dim trans as sqltransacton

con.open()''connection open
trans=con.BeginTransaction
try
trans.commit
catch
trans.rollback
end try

Got it by using

Dim Transaction As SqlCeTransaction = sqlcon.BeginTransaction

and then continuing as usual for a transaction. Thanks a bunch

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.