Search code examples
c#.netasp.netsubsonicsubsonic3

Updating my database


I am new with the subsonic, and I have a problem when trying to update the database from the sql server. I have created a gridview by still is not returning the updates results. can you please help me? its getting an error code on dc.AddMostaHse(); (Cannot implicity convert type 'void to 'object')

Here is the code being done of DataAccess.cs page

public void AddMostaHse() {

        Mosta.MostaHSE1 xx = new MostaHSE1();
        xx.ID = 94;
        xx.FunctionLocation = "lza94";
        xx.acno = 12;
        xx.Save();
    }

Binding it with the gridview. {

        DataAccess dc = new DataAccess();
        gvtest.DataSource = dc.AddMostaHse();
        gvtest.DataBind();

    }

Solution

  • This doesn't make much sense. Your gridview should be being bound from a Read operation. You are currently binding it to a Insert/Write operation based on what you have provided. You should probably be grabbing a collection of MostaHSE1() and displaying that in your gridview. The return type of your Read function should most likely be DataTable or DataSet.

    Your AddMostHse1() appears it should work, but you want to target a different event off of the gridview to do this. Maybe RowEditEnding or some other event.