vb.net deleteing form sql db???

How would i correct this code so it will delete form my db?

Shared Function deleteit(ByVal thedate As DateTime, ByVal myname As String) As Integer
        Dim con As New SqlConnection(local)
        Dim cmd As New SqlCommand
        cmd.Connection = con
        Try
            con.Open()
            Dim theres As Integer
            cmd.Parameters.AddWithValue("@date", thedate)
            cmd.Parameters.AddWithValue("@myname", myname)
            cmd.CommandText = "Delete * from Holidays where Date=@date and UserName = @myname"
            theres = cmd.ExecuteScalar()
            Return theres
        Catch ex As Exception
            Throw ex
        Finally
            con.Close()
        End Try
    End Function

Open in new window

runnerjp2005Asked:
Who is Participating?
 
LimbeckConnect With a Mentor Commented:
           cmd.CommandText = "Delete from Holidays where ""Date""=@date and UserName = @myname"

0
 
LimbeckCommented:
how about

          cmd.CommandText = "Delete from Holidays where Date=@date and UserName = @myname"
 
0
 
LimbeckCommented:
not sure about your coolumnname date though. its a reserved word, can you change it?

            cmd.CommandText = "Delete from Holidays where 'Date'=@date and UserName = @myname"
0
 
runnerjp2005Author Commented:
i now get

Exception Details: System.Data.SqlClient.SqlException: Conversion failed when converting datetime from character string.
0
 
runnerjp2005Author Commented:
jus to note i convetrted it here        dateallreadybooked.deleteit(DateTime.Parse(result.Split("|")(1)), "Jarratt")
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.