473,468 Members | 1,423 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problem calling Fill() method

I have several tables involved in my application, but the two in question
here are the company and address tables. The company table has
business_address_id and mailing_address_id columns, which are both foreign
keys to the address table.

So, the stored procedure to which my SelectCommand points to reads as:

ALTER PROCEDURE dbo.CompanyInfoByCompanyID
(
@companyid int
)
AS
SET NOCOUNT ON
SELECT * FROM Company WHERE company_id = @companyid
SELECT * FROM Address
WHERE (address_id IN (Select business_address_id From
Company Where company_id = @companyid))
OR (address_id IN (Select mailing_address_id From Company
Where company_id = @companyid))
RETURN

Whenever I attempt to add a new row into the Address table using my
daAddress dataset, the update works fine and even enters a new row inside
the Address table. However, when I attempt to refresh my datagrid by
calling the Fill() method on the Address adapter I get the following error:

Exception Details: System.Data.SqlClient.SqlException: UPDATE statement
conflicted with COLUMN FOREIGN KEY constraint 'Address_Company_FK1'. The
conflict occurred in database 'OFS', table 'Address', column 'address_id'.
I placed the Find() call in a try/catch block, and upon closer inspection
discovered this error message:

DataSet errors: dsCompanyInfo

Table: Address

Row Error: Column 'zip' does not allow DBNull.Value.

Now, the zip column is indeed populated upon calling the Update() method,
and it is populated in the database. So I have no idea where this error
message is coming from.

Your assistance would be greatly appreciated,

Mervin Williams
Nov 18 '05 #1
4 1586
Mervin:

The part about the Update statement failing when you call Fill, I'd think
that it would be calling your select statement instead of update statement.
What does the update statement look like, and is this the select command
fill is pointing to.
"Mervin Williams" <mw*******@innovasolutions.net> wrote in message
news:O0**************@TK2MSFTNGP09.phx.gbl...
I have several tables involved in my application, but the two in question
here are the company and address tables. The company table has
business_address_id and mailing_address_id columns, which are both foreign
keys to the address table.

So, the stored procedure to which my SelectCommand points to reads as:

ALTER PROCEDURE dbo.CompanyInfoByCompanyID
(
@companyid int
)
AS
SET NOCOUNT ON
SELECT * FROM Company WHERE company_id = @companyid
SELECT * FROM Address
WHERE (address_id IN (Select business_address_id From
Company Where company_id = @companyid))
OR (address_id IN (Select mailing_address_id From Company
Where company_id = @companyid))
RETURN

Whenever I attempt to add a new row into the Address table using my
daAddress dataset, the update works fine and even enters a new row inside
the Address table. However, when I attempt to refresh my datagrid by
calling the Fill() method on the Address adapter I get the following error:
Exception Details: System.Data.SqlClient.SqlException: UPDATE statement
conflicted with COLUMN FOREIGN KEY constraint 'Address_Company_FK1'. The
conflict occurred in database 'OFS', table 'Address', column 'address_id'.
I placed the Find() call in a try/catch block, and upon closer inspection
discovered this error message:

DataSet errors: dsCompanyInfo

Table: Address

Row Error: Column 'zip' does not allow DBNull.Value.

Now, the zip column is indeed populated upon calling the Update() method,
and it is populated in the database. So I have no idea where this error
message is coming from.

Your assistance would be greatly appreciated,

Mervin Williams

Nov 18 '05 #2
It is the Select that is failing when I call the Fill() method, and is
causing the errors that I wrote in my earlier message below. That's what is
so puzzling.

The update statement is a straightforward update to the Address table
(actually generated by VS.NET). Here it is:

UPDATE Address
SET address_line1 = @address_line1, address_line2 = @address_line2, city =
@city, state = @state, zip = @zip
WHERE (address_id = @Original_address_id) AND (address_line1 =
@Original_address_line1) AND (address_line2 = @Original_address_line2 OR
@Original_address_line2 IS NULL AND address_line2 IS NULL) AND (city =
@Original_city) AND (state = @Original_state) AND (zip = @Original_zip);
SELECT address_id, address_line1,
address_line2, city, state, zip
FROM Address
WHERE (address_id = @address_id)

Mervin Williams

"William Ryan eMVP" <do********@comcast.nospam.net> wrote in message
news:eG**************@TK2MSFTNGP09.phx.gbl...
Mervin:

The part about the Update statement failing when you call Fill, I'd think
that it would be calling your select statement instead of update statement. What does the update statement look like, and is this the select command
fill is pointing to.
"Mervin Williams" <mw*******@innovasolutions.net> wrote in message
news:O0**************@TK2MSFTNGP09.phx.gbl...
I have several tables involved in my application, but the two in question here are the company and address tables. The company table has
business_address_id and mailing_address_id columns, which are both foreign keys to the address table.

So, the stored procedure to which my SelectCommand points to reads as:

ALTER PROCEDURE dbo.CompanyInfoByCompanyID
(
@companyid int
)
AS
SET NOCOUNT ON
SELECT * FROM Company WHERE company_id = @companyid
SELECT * FROM Address
WHERE (address_id IN (Select business_address_id From Company Where company_id = @companyid))
OR (address_id IN (Select mailing_address_id From Company Where company_id = @companyid))
RETURN

Whenever I attempt to add a new row into the Address table using my
daAddress dataset, the update works fine and even enters a new row inside the Address table. However, when I attempt to refresh my datagrid by
calling the Fill() method on the Address adapter I get the following

error:

Exception Details: System.Data.SqlClient.SqlException: UPDATE statement
conflicted with COLUMN FOREIGN KEY constraint 'Address_Company_FK1'. The
conflict occurred in database 'OFS', table 'Address', column 'address_id'. I placed the Find() call in a try/catch block, and upon closer inspection discovered this error message:

DataSet errors: dsCompanyInfo

Table: Address

Row Error: Column 'zip' does not allow DBNull.Value.

Now, the zip column is indeed populated upon calling the Update() method, and it is populated in the database. So I have no idea where this error
message is coming from.

Your assistance would be greatly appreciated,

Mervin Williams


Nov 18 '05 #3
I know that it was fill, but you could use a String for your commandtext.
That string could say "Update Tbl_Whatever" just as easily as "Select From
Tbl_Whatever" I was wondering if the Select Command is pointing to the
right statement and if possibly it's being set to something else. Since you
normally just fire a Select statement with Fill, it seems like something is
pointing incorrectly.
"Mervin Williams" <mw*******@innovasolutions.net> wrote in message
news:eZ**************@TK2MSFTNGP11.phx.gbl...
It is the Select that is failing when I call the Fill() method, and is
causing the errors that I wrote in my earlier message below. That's what is so puzzling.

The update statement is a straightforward update to the Address table
(actually generated by VS.NET). Here it is:

UPDATE Address
SET address_line1 = @address_line1, address_line2 = @address_line2, city =
@city, state = @state, zip = @zip
WHERE (address_id = @Original_address_id) AND (address_line1 =
@Original_address_line1) AND (address_line2 = @Original_address_line2 OR
@Original_address_line2 IS NULL AND address_line2 IS NULL) AND (city =
@Original_city) AND (state = @Original_state) AND (zip = @Original_zip);
SELECT address_id, address_line1,
address_line2, city, state, zip
FROM Address
WHERE (address_id = @address_id)

Mervin Williams

"William Ryan eMVP" <do********@comcast.nospam.net> wrote in message
news:eG**************@TK2MSFTNGP09.phx.gbl...
Mervin:

The part about the Update statement failing when you call Fill, I'd think
that it would be calling your select statement instead of update

statement.
What does the update statement look like, and is this the select command
fill is pointing to.
"Mervin Williams" <mw*******@innovasolutions.net> wrote in message
news:O0**************@TK2MSFTNGP09.phx.gbl...
I have several tables involved in my application, but the two in

question here are the company and address tables. The company table has
business_address_id and mailing_address_id columns, which are both foreign keys to the address table.

So, the stored procedure to which my SelectCommand points to reads as:

ALTER PROCEDURE dbo.CompanyInfoByCompanyID
(
@companyid int
)
AS
SET NOCOUNT ON
SELECT * FROM Company WHERE company_id = @companyid
SELECT * FROM Address
WHERE (address_id IN (Select business_address_id From Company Where company_id = @companyid))
OR (address_id IN (Select mailing_address_id From Company Where company_id = @companyid))
RETURN

Whenever I attempt to add a new row into the Address table using my
daAddress dataset, the update works fine and even enters a new row inside the Address table. However, when I attempt to refresh my datagrid by
calling the Fill() method on the Address adapter I get the following

error:

Exception Details: System.Data.SqlClient.SqlException: UPDATE statement conflicted with COLUMN FOREIGN KEY constraint 'Address_Company_FK1'. The conflict occurred in database 'OFS', table 'Address', column 'address_id'. I placed the Find() call in a try/catch block, and upon closer inspection discovered this error message:

DataSet errors: dsCompanyInfo

Table: Address

Row Error: Column 'zip' does not allow DBNull.Value.

Now, the zip column is indeed populated upon calling the Update() method, and it is populated in the database. So I have no idea where this error message is coming from.

Your assistance would be greatly appreciated,

Mervin Williams



Nov 18 '05 #4
the exception states that the update command is executing.. ..
and if the exception occurred when .fill() executed, then u shud check code
logic, whether ur update statement executing on a call to fill() is correct.

anyway.. post some .net code (parts which relate to this err), so that its
easier to understand the problem.

'Harish

"Mervin Williams" <mw*******@innovasolutions.net> wrote in message
news:O0**************@TK2MSFTNGP09.phx.gbl...
I have several tables involved in my application, but the two in question
here are the company and address tables. The company table has
business_address_id and mailing_address_id columns, which are both foreign
keys to the address table.

So, the stored procedure to which my SelectCommand points to reads as:

ALTER PROCEDURE dbo.CompanyInfoByCompanyID
(
@companyid int
)
AS
SET NOCOUNT ON
SELECT * FROM Company WHERE company_id = @companyid
SELECT * FROM Address
WHERE (address_id IN (Select business_address_id From
Company Where company_id = @companyid))
OR (address_id IN (Select mailing_address_id From Company
Where company_id = @companyid))
RETURN

Whenever I attempt to add a new row into the Address table using my
daAddress dataset, the update works fine and even enters a new row inside
the Address table. However, when I attempt to refresh my datagrid by
calling the Fill() method on the Address adapter I get the following error:
Exception Details: System.Data.SqlClient.SqlException: UPDATE statement
conflicted with COLUMN FOREIGN KEY constraint 'Address_Company_FK1'. The
conflict occurred in database 'OFS', table 'Address', column 'address_id'.
I placed the Find() call in a try/catch block, and upon closer inspection
discovered this error message:

DataSet errors: dsCompanyInfo

Table: Address

Row Error: Column 'zip' does not allow DBNull.Value.

Now, the zip column is indeed populated upon calling the Update() method,
and it is populated in the database. So I have no idea where this error
message is coming from.

Your assistance would be greatly appreciated,

Mervin Williams

Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: cody | last post by:
I have to write an algorithm with must ensure that objects are put in buckets (which are always 4 in size). The objects have two properties: A and B. It is not allowed that in a bucket are objects...
3
by: Phil | last post by:
Hi, I have a client/server app. that uses a windows service for the server and asp.net web pages for the client side. My server class has 3 methods that Fill, Add a new record and Update a record....
7
by: pei_world | last post by:
the following codes are error occurs. basically, I set a breakpoint at BuildingTN, I trace it, and it come up my intended table, but when I run the program, in my component cobInside, it always...
3
by: Suhail Salman | last post by:
Dear All, i got the following error message in an applications that opens 13 threads and all of them calling a stored procedure which retreieves data from SQLServer and fills them to a table the...
4
by: Joerg M. Colberg | last post by:
Hi all, I have a problem when using a DataSet. I am using it to query a SQLServer database as follows. In my code it looks like SqlDataAdapter eDA = new SqlDataAdapter(sqlcmd); // where...
10
by: Saso Zagoranski | last post by:
hi, this is not actually a C# problem but since this is the only newsgroup I follow I decided to post my question here (please tell me where to post this next time if you think this post...
2
by: Mike Hutton | last post by:
I have a rather odd problem. I have a SP which uses temp. tables along the way, and then returns a table of results: CREATE PROCEDURE dbo.usp_myproc( @pNameList VARCHAR(6000) ) AS
2
by: ajikoe | last post by:
Hi, I tried to follow the example in swig homepage. I found error which I don't understand. I use bcc32, I already include directory where my python.h exist in bcc32.cfg. /* File : example.c...
1
by: Rachana | last post by:
Hi, I am having vb2003-net 1.1 Code was working fine yesterday, today getting error ----------------------------------------------------------- error: An unhandled exception of type...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.