hi i'm having a problem regarding sql deleteCommand..
can someone please help me solve this problem coz it takes a lot of time for me to figure it out..

here's my code

Private Sub btnDeleteBC_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDeleteBC.Click
        If MessageBox.Show("Do you really want to Delete this Record?", _
"Delete", MessageBoxButtons.YesNo, _
MessageBoxIcon.Warning) = DialogResult.No Then

            MsgBox("Operation Cancelled")
            Exit Sub
        End If

        da.DeleteCommand = New SqlCommand("DELETE FROM Blood_Chemistry WHERE BC_Form_ID= @BC_Form_ID", cs)


    End Sub

It appears you are not setting the parameter?

why not use a textbox to enter the id

str = "delete from blood_chemistry where BC_form_ID='" & Bc_form_id.text & "'",cs)

enter the id in textbox... Bc_form_id.text


da.DeleteCommand = New SqlCommand(""delete from blood_chemistry where BC_form_ID='" & Bc_form_id.text & "'",cs)

' after Line 11
Dim param As SqlParameter = New SqlParameter("@BC_FORM_ID", SqlDbType.NVarChar, 16)
  param.Value = BC_FORM_ID.TEXT
  da.Deletecommand.parameters.Add (param)

thanks for your reply

i have seen a c# code just like this

da.DeleteCommand = New SqlCommand("DELETE FROM Blood_Chemistry WHERE BC_Form_ID= @BC_Form_ID", cs)

da.deletecommand.parameters.add("@BC_Form_ID", SqlDbType.varchar).value = ds.tables(0).rows(tablename.position)(0);

i tried this one but i got an error saying tablename is not declared

Maybe this will help, i use this when i want to delete something in the database through VB

Dim connection As New SqlClient.SqlConnection
            Dim command As New SqlClient.SqlCommand
            Dim adaptador As New SqlClient.SqlDataAdapter
            Dim dataset As New DataSet
            connection.ConnectionString = ("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Main.mdf;Integrated Security=True;User Instance=True")
            command.CommandText = "DELETE FROM VentasDD WHERE folio = " & FolioTB.Text & " ;"

            command.Connection = connection
            adaptador.SelectCommand = command

but what if instead of textbox, i want to delete from a datagridview??