We help IT Professionals succeed at work.
Get Started

winform update sql not working on real DB but fine in form!

Last Modified: 2015-03-11
Hi i am making a desktop windows application, students and courses and grades.
i use VS2010 ultimate, windows 8.
the database i used is from within VS2010 (.mdf) i added it as new item to the project (service based DB).

all works fine for select statements and showing data in gridviews and whatnot...
until i tried to update records through a button. after updating it should reflect and show the new values in the datagridview ....

update works ok on the winform (provided i have to click update twice dont know why!) and that is while form is open.
when i close the form and re-open it the records shown as the previous ones and old values were not updated.

my code for the button:

   Dim myGridTable As New DataTable()
                ' i assumed it needs this---not working---> PssDBDataSet.EnforceConstraints = False

                gridAdapter.SelectCommand = New SqlCommand("update enroll set MID = '" & lblRezMid.Text & "' where cid ='" & cidCB.Text & "' ", conn)

                ' i assumed it needs this---not working--->  gridAdapter.Fill(PssDBDataSet, "Enroll")
                ' i assumed it needs this---not working--->  gridAdapter.Update(PssDBDataSet, "Enroll")

            Catch ex As Exception
                If gridAdapter IsNot Nothing Then
                End If

            End Try

Open in new window

there are strings and numbers but like i mentioned, during form operation it shows good interactivity, but changes wont reflect on the real DB when i open it from visual studio (database name pssDB.mdf)

please help!
Watch Question
This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE