Question VS 2010 Crashes when I try to modify DataAdapter select statement when running app

emaduddeen

Well-known member
Joined
May 5, 2010
Messages
171
Location
Lowell, MA & Occasionally Indonesia
Programming Experience
Beginner
Hi Everyone,

I wanted to re-configure a DataAdapter and VS 2010 allowed me to change the Select statement in the wizard and all appeared ok until I tried to run the app.

The attachment shows the error. After saving the app after many time clicking the Ok button many times I loaded the app again and it ran.

Is this a bug with VS 2010 ?

How do I get around this any time we want to change the DataAdapter?

Truly,
Emad
 

Attachments

  • VS Crash.jpg
    VS Crash.jpg
    331.2 KB · Views: 30
I was not aware of this bug, did you try reinstalling VS 2010?
 
First up, why would you use DataAdapters in the designer? If you're going to comingle your data access and presentation logic then why not use the Data Source wizard and create a typed DataSet?

As for the question, from the error message, I suspect the issue is to do with a data-binding that could not be successfully updated when you changed the data access code.

Just like all software, VS does harbour bugs. It's pretty much unthinkable that such a complex application would be bug free. If you find one then you can always log it on Connect but, in this case, I doubt they would address it. They'd probably tell you exactly what I did in the first paragraph above.
 
Hi,

Thanks for the reply. I read the MSDN article on how to do that.

I do have another question and I believe I'm missing some code here.

We are trying to insert a row into to database but the data is not really inserted in SQL Server.

Here's the code from clicking the "New" button:
VB.NET:
    Private Sub RibbonButtonInsert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RibbonButtonInsert.Click

        mbAddNew = True

        ' Using the BindingContext class add a new record.
        '-------------------------------------------------
        Me.BindingContext(DataSetCustomerIndividual, "Customers").AddNew()

        ActivateEditing(True)

    End Sub

And this is for the "Save" button:
VB.NET:
    Private Sub SaveRecord()

        Dim intTotalRows As Integer

        ' Apply changes to the data source.
        '----------------------------------
        CustomerIndividualBindingSource.EndEdit()

        ' Save the changes from the DataTable to the database.
        '-----------------------------------------------------
        intTotalRows = SqlDataAdapterCustomerIndividual.Update(DataSetCustomerIndividual, "Customers")

    End Sub

This code works for edits but not inserts so I believe I missed something here. Again the code for inserts is from that outdated book I got help from you before.

When the Insert button is used and then the Save button is used intTotalRows returns 0.

Thanks.

Truly,
Emad
 
Emad,

I'm glad you found another solution, mine was kind of general :)

-Josh
 
Emad,

I can try, but I do not do databases at all :) Could you post whatever code you were using for the edit?

-Josh
 
Back
Top