HOW TO ENABLE AND DISABLE FOREIGN KEY THROUGH CODING
Private Sub InsertStockDatagrid()
    con.Open()
    For Each Rw As DataGridViewRow In DataGridView1.Rows
        'For RW As Integer = 0 To DataGridView1.Rows.Count - 1
        Dim cmd = New SqlCommand("Insert into Stock (Code, Qty, Rate, Amt, Taxable, cgstamt, sgstamt,Type,Prefix,Srl,Branch) values('" & Rw.Cells(15).Value.ToString() & "','" & Rw.Cells(6).Value.ToString() & "','" & Rw.Cells(7).Value.ToString() & "','" & Rw.Cells(13).Value.ToString() & "','" & Rw.Cells(13).Value.ToString() & "','" & Rw.Cells(11).Value.ToString() & "','" & Rw.Cells(12).Value.ToString() & "','" & ComboBoxTranType.Text & "','" & Lblprefix.Text & "','" & TextINVNo.Text & "','" & LBLBranchcode.Text & "')", con)
        cmd.ExecuteNonQuery()
    Next
    Updatestocksrl()
    MessageBox.Show("Stock Data Entered")
    con.Close()
End Sub
 
    