I have two tables major and student

majorname is the foreign key of Student table
Student primary key=Reg_No

I want to delete entire student record from student i used the coding like this...........

  Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
        myConnection = New SqlConnection(connectionstring)
        myConnection.Open()



        myCommand = New SqlCommand("DELETE From(Student)Where =(Select MajorName from Major Where  MajorName = '" & cmbMajorI.Text & "'", myConnection)
        myCommand.ExecuteNonQuery()
        MsgBox("CORRECT")
        myConnection.Close()

    End Sub

but i got the error like this :Incorrect syntax near '('. Incorrect syntax near 'Electronics'.
Electronics is one of major name

The SQL query you want is

"DELETE From Student Where MajorName = '" & cmbMajorI.Text & "'"
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.