I work with Visual basic 2010 express and Sql server 2008 Express
I established Person and Specialist tables data base .I want to make Insert /update/ delete
Here object declarations in a module :
Public str As String 'string sqlcommand
Public con As New SqlConnection("Data source =Sara\SQLEXPRESS ; initial catalog= ADHD_DIAGNOSIS_SYSTEM ;Integrated Security =True ")
Public com As SqlCommand
Public DataSet As New DataSet()
Public Specialistadapter As New SqlDataAdapter("Select * from SPECIALISTS ", con)
Public Personadapter As New SqlDataAdapter("Select * from PERSON", con)
Public SpecialistCommandBuilder As New SqlCommandBuilder(Specialistadapter)
Public PersonCommandBuilder As New SqlCommandBuilder(Personadapter)
'' declare tables
Public tblPerson As DataTable
Public tblSpecialist As DataTable
Public tblSession As DataTable
'' declare records
Public PersonCurrent As DataRow
Public SpecialistCurrent As DataRow
at load project this Sub main is called:
Specialistadapter.FillSchema(DataSet, SchemaType.Source, "SPECIALISTS")
Specialistadapter.Fill(DataSet, "SPECIALISTS")
'Fill second table
Personadapter.FillSchema(DataSet, SchemaType.Source, "PERSON")
Personadapter.Fill(DataSet, "PERSON")
tblSpecialist = DataSet.Tables("SPECIALISTS")
tblPerson = DataSet.Tables("PERSON")
when delete btn is clicked delete is called :
sub delete ()
Personadapter.DeleteCommand = New SqlCommand("delete from PERSON where SSN = @PersonSSN", con)
Personadapter.DeleteCommand.Parameters.Add("PersonSSN", SqlDbType.VarChar, 50, "SSN").Value = PersonForm.SSNTextBox.Text
PersonCommandBuilder.GetDeleteCommand()
Personadapter.Update(DataSet, "PERSON")
MsgBox("Record deleted successfully")
But this code does not delete the record
:'(
Plz help me
:(