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

  • SEARCH
  • Home
  • 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 3497282
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:21:06+00:00 2026-05-18T12:21:06+00:00

I use stored procs to get data from db (ms sql 2008 r2 express).

  • 0

I use stored procs to get data from db (ms sql 2008 r2 express). Two fields in source table may contain NULL values so when i add data source to my project in VS in database designer i set nullable fields’ AllowDBNull property to True and NullValue property to (Empty) (both are string fields).

Despite all those actions i get exception every time generated datatadapter tries to get row with null values. I’ve checked everything: AllowDBNull is True, NullValue is (Empty), no unique keys are in the table.

What the hell is wrong with my code?

UPD “Exception message: Failed to enable constraints. One or more rows contain values
violating non-null, unique, or foreign-key constraints.”

Code:

foreach (BusStationDataSet.selectCarrierListRow row in _tblSource.Rows)
                    {
//Next line of code throws exception
                        BusStationDataSet.selectCarrierPhonesDataTable _tblPhones = _taPhones.GetData(row.carrierId, Settings.Default.DataLanguage);
                        phones = string.Empty;
                        int i = 0;

                        foreach (BusStationDataSet.selectCarrierPhonesRow phoneRow in _tblPhones.Rows)
                        {
                            i++;
                            string end = i == _tblPhones.Rows.Count ? "" : ", ";

                            phones += (phoneRow.countryCode != string.Empty ? phoneRow.countryCode : "") + (phoneRow.regionCode != string.Empty ? " (" + phoneRow.regionCode + ") " : "") + phoneRow.number +
                                end;
                        }
                        phones = phones == string.Empty ? MultilangInterface.Instance.GetMessageString(MultilangInterface.Messages.NullValue) : phones;

                        _dsDestination.Tables["Carrier"].Rows.Add(new object[]{
                            null,
                            row.carrierId,
                            row.title,
                            row.carrierType,
                            row.country,
                            row.city,
                            row.country + ", " + row.region + ", " + row.city + ", " + row.street + ", " + row.building + (string.IsNullOrEmpty(row.addressLine)?"":", " + row.addressLine),
                            row.lastName +" "+ row.firstName +" "+ row.middleName,
                            phones
                        });
                    }
  • 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-18T12:21:07+00:00Added an answer on May 18, 2026 at 12:21 pm

    Finally I’ve found the issue. There were two generated tables in project’s dataset with almost similar names: selectCarriersPhonesDataTable and selectCarrierPhonesDataTable. The second one was the source of exception because for both of nullable fields the NullValue property was set to (Throw Exception). After I got rid of this diambiguation everything turned out to be working flawless. Definitely I should get enough sleep 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Coming from the MS SQL world, I tend to make heavy use of stored
I'd like to use . to call sql script from inside a stored proc
I am attempting to use the SQL SERVER 2008 MERGE statement in a stored
We use SQL Server 2005. All our data access is done through stored procedures.
We have a helper class that we use to call stored procs on SQL
I have two stored procedures I wish to use in my stored procedure, but
Is there any way to use Dapper.NET with stored procs that return multiple result
I am currently trying to use JavaMail to get emails from IMAP servers (Gmail
I have a data-source connected to a stored proc that will return the one
We have a SQL server 2008 and one of the tables, say table A

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.