Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6154793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:19:17+00:00 2026-05-23T20:19:17+00:00

I have a small application which consists of a DAL, BLL and the Application

  • 0

I have a small application which consists of a DAL, BLL and the Application itself all in different projects under one solution in Visual Studio 2010.

My DAL is using an xsd file to query the database and my BLL has methods to get the information from the DAL and do stuff with it.

Currently I am trying to insert a record using the code behind of the application to make a call to a method in the BLL which then attempts to insert the record by using the Tableadapter.Update() method generated in the xsd file of the DAL.

I can already select and update records with no problem, but I can’t insert records.

As far as I know the TableAdapter.Update() method should know to insert a new record if I provide it with a new row, however it is returning a value of 0 – meaning 0 rows were affected, so it isn’t working.

The table I am trying to insert into is called tblRoles.

It has an ‘ID’ column, which is an int, primary key and identity column. It has a ‘Name’ column which takes nvarchar(50), and it has 4 ‘CanAdduser’ etc columns which take a type of bit.

Here is my code:

APP code behind:

protected void CreateRole(object sender, EventArgs e) {
    RolesBL roles = new RolesBL();

    roles.CreateRole(NewRoleName.Text);

    RolesGridView.DataBind();
}

BLL:

private tblRolesTableAdapter adapter = new tblRolesTableAdapter();

public bool CreateRole(string Name) {
    CMSDS.tblRolesDataTable roles = new CMSDS.tblRolesDataTable();
    CMSDS.tblRolesRow row = roles.NewtblRolesRow();

    row.Name = Name;
    row.CanAddUsers = false;
    row.CanEditUsers = false;
    row.CanSuspendUsers = false;
    row.CanChangeUserPasswords = false;

    int result = adapter.Update(row);

    if(result == 1) {
        return true;
    }

    return false;
}

From what I understand this should insert a new row into the table, but adapter.Update(row) keeps on returning a 0 and I don’t know why.

When I debug I can see that all of the row columns have been assigned the correct values, and no errors are thrown.

Any help would be appreciated!

Edit:

I forgot to mention that when I configured the default Fill,GetData() query in the xsd file I did make sure that it auto generated Insert, Update and Delete statements.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T20:19:17+00:00Added an answer on May 23, 2026 at 8:19 pm

    You haven’t added the new Role-Row to the DataTable.

    CMSDS.tblRolesDataTable roles = new CMSDS.tblRolesDataTable();
    CMSDS.tblRolesRow row = roles.NewtblRolesRow();
    row.Name = Name;
    roles.AddtblRolesRow(row); 
    int result = adapter.Update(roles); //the same as `adapter.Update(row)`
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have small chess application which consists of cells and boards. When user moves
I have created a small application which opens,reads and creates Excel files. The app
I have written a small java application for which I need to obtain performance
I want to globalize my application. I have created a small form which asks
In my application I have a window which I popup with small messages on
I have a small application I am working on that at one point needs
I have a small application which is much like a clock. It has been
I have a small application which sends files over the network to an agent
I have developed a small C# form application which calls a web service. Everything
I have a small application which automates Microsoft Word via COM/OLE Automation. Unfortunately this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.