Showing posts with label app. Show all posts
Showing posts with label app. Show all posts

Monday, March 26, 2012

Insert xml into mssql 2000

Hi,

I have app with file selection field. Users can shoose xml file from their local hard disk and click Save. When they click save, content of xml file should be inserted into mssql 2000.

What is the most efficient way to do this using C#2005 and mssql2000?

Any good article or tutorial?

http://www.databasejournal.com/features/mssql/article.php/2204421|||http://aspalliance.com/477

Monday, March 12, 2012

INSERT Statement Error

I have a web app w/a form that takes user data and inserts into a customers
table. Now if I try to insert a record w/identical 'customerName', this is
the error:
INSERT statement conflicted with COLUMN FOREIGN KEY constraint
'FK_transactions_customers'. The conflict occurred in database 'CHZ', table
'customers', column 'CID'.
Now the constraint 'FK_transactions_customers' uses CID.Customers as my
Primary key and Trans.CID as the foreign key. I can't seem to figure out wh
y
the error is thrown when using an existing 'customerName'.
Here's the ddl:
CREATE TABLE [customers] (
[CID] [int] IDENTITY (1, 1) NOT NULL ,
[customerName] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[customerID] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[address] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[city] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[state] [varchar] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[zip] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[phone] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[email] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[CDB] [bit] NULL ,
CONSTRAINT [PK_customers] PRIMARY KEY NONCLUSTERED
(
[CID]
) ON [PRIMARY]
) ON [PRIMARY]
GO
TIA for help.Post the DDL for Trans, as well as the offending INSERT statement.
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinpub.com
"Eric" <Eric@.discussions.microsoft.com> wrote in message
news:FB917852-FA0D-4EE8-B6DD-15A142D3B934@.microsoft.com...
I have a web app w/a form that takes user data and inserts into a customers
table. Now if I try to insert a record w/identical 'customerName', this is
the error:
INSERT statement conflicted with COLUMN FOREIGN KEY constraint
'FK_transactions_customers'. The conflict occurred in database 'CHZ', table
'customers', column 'CID'.
Now the constraint 'FK_transactions_customers' uses CID.Customers as my
Primary key and Trans.CID as the foreign key. I can't seem to figure out
why
the error is thrown when using an existing 'customerName'.
Here's the ddl:
CREATE TABLE [customers] (
[CID] [int] IDENTITY (1, 1) NOT NULL ,
[customerName] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
,
[customerID] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[address] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[city] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[state] [varchar] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[zip] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[phone] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[email] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[CDB] [bit] NULL ,
CONSTRAINT [PK_customers] PRIMARY KEY NONCLUSTERED
(
[CID]
) ON [PRIMARY]
) ON [PRIMARY]
GO
TIA for help.|||You are trying to insert a customer which isn=B4t present in the
transaction table. Check this.
HTH, jens Suessmeyer.|||"Jens" wrote:

> You are trying to insert a customer which isn′t present in the
> transaction table. Check this.
> HTH, jens Suessmeyer.
>
Shouldn't be a problem, unless the foreign key constraint is backwards
(customers references transactions instead of transactions references
customers).