Private Sub saveBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles saveBtn.Click addSubject() End Sub Private Function addSubject() As Boolean Dim cmd As New SqlCommand Dim ok As Boolean = False cmd.Connection = con cmd.CommandText = " INSERT INTO Subjects(subject_name) VALUES(@inn)" cmd.CommandType = CommandType.Text cmd.Parameters.AddWithValue("inn", subjectTxt.Text) Try con.Open() cmd.ExecuteNonQuery() ok = True Catch ex As Exception MessageBox.Show(ex.Message, "Add failed") ok = False End Try cmd.Dispose() con.Close() Return ok con.Close() End Function
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)