Hi everyone,
I have 3 tables:
[code]
CREATE TABLE [flowsuitedata].[Complaint](
[ComplaintId] [int] NOT NULL,
[OrderNumber] [int] NULL,
[InvoiceNumber] [int] NULL,
[DescriptionComplaint] [ntext] NULL,
[CustomerContactPerson] [ntext] NULL,
[OwnContactPerson] [ntext] NULL,
[ResolutionDescription] [nvarchar](50) NULL,
[RelatedSuborder] [nvarchar](50) NULL,
[Responsible] [nvarchar](50) NULL,
[StatusComplaint] [varchar](50) NULL,
[Amount] [int] NULL,
[StartDateComplaint] [datetime] NULL,
[EndDateComplaint] [datetime] NULL,
[ComplaintAssignedOwnContactPerson] [ntext] NULL,
[ResponsibleId] [int] IDENTITY(1,1) NOT NULL,
[StatusId] [int] NOT NULL,
CONSTRAINT [PK_Complaint] PRIMARY KEY CLUSTERED
[/code]
[code]
[code]
CREATE TABLE [flowsuitedata].[Status](
[StatusId] [int] IDENTITY(1,1) NOT NULL,
[Kind_status] [varchar](50) NULL,
CONSTRAINT [PK_Status] PRIMARY KEY CLUSTERED
(
[StatusId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
[/code]
CREATE TABLE [flowsuitedata].[Responsible](
[ResponsibleId] [int] IDENTITY(1,1) NOT NULL,
[Kind_Responsible] [varchar](50) NULL,
CONSTRAINT [PK_Responsible] PRIMARY KEY CLUSTERED
(
[ResponsibleId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
[/code]
But I still get the error:
"Cannot insert the value NULL into column 'StatusId', table 'XeroxTest.flowsuitedata.Complaint'; column does not allow nulls. INSERT fails."
by this query:
[INSERT INTO Complaint(InvoiceNumber, DescriptionComplaint,CustomerContactPerson,OwnContactPerson,ResolutionDescription,RelatedSuborder,Responsible,StatusComplaint,Amount,StartDateComplaint,EndDateComplaint, ComplaintAssignedOwnContactPerson)
VALUES(77, 'hoi', 'hoi', 'hoi', 'hoi', 'hoi', 'hoi','hoi',99,'10/4/2011','10/4/2011', 'hallo');]
And I have put in every table set the property: Is Identity to Yes.
THX for helping!!
Loading

Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 5, 2011, 1:11 PM EDT
Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 4, 2011, 5:43 AM EDT
I do not see StatusId being defined as IDENTITY in your code for the Table Complaint, also in your INSERT statement ComplaintId and ResponsibleId is not passed and that is defined as NOT NULL in your table.
Please do not forget to mark "Accepted Answer"
albert albertRank #2,683 · 519 reputationPosted Oct 4, 2011, 6:04 AM EDT
The ideer is: 3 tables: PK in table complaint and then 2 FK in the table Complaint. The two FK in the table: Complaint are: StatusId en ResponsibleId.
Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 4, 2011, 6:10 AM EDT
Please do not forget to mark "Accepted Answer".
albert albertRank #2,683 · 519 reputationPosted Oct 4, 2011, 6:14 AM EDT
Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 4, 2011, 6:15 AM EDT
Please do not forget to mark "Accepted Answer".
albert albertRank #2,683 · 519 reputationPosted Oct 4, 2011, 6:21 AM EDT
albert albertRank #2,683 · 519 reputationPosted Oct 4, 2011, 6:24 AM EDT
Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 4, 2011, 6:28 AM EDT
Please do not forget to mark "Accepted Answer".
albert albertRank #2,683 · 519 reputationPosted Oct 4, 2011, 7:15 AM EDT
other question: I have by status: 3 options: Open, approved and Cancelled.
I have the listbox with the three values so the user can choose 1 of the 3 values. But how do u put the values if the user has choosed 1 of the 3 values in the SQL database?
THX
Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 4, 2011, 7:32 AM EDT
General Algo:
Open Connection
Create Command
Assign Parameters (if you have stored procedure)
Execute Command (give your SQL)
Close Connection
Dispose
albert albertRank #2,683 · 519 reputationPosted Oct 4, 2011, 11:08 PM EDT
I can add all the values in the complaint table.
But the values: status and Respobible are not added in the database.
But if u can see: I have made an table: status with the columns: statusId and Kind_Status. And then in the form of the Complaint the user can choose: Open, Approved and Cancelled.
I Have made the column: Kind_Status varchar(50) is this the correct datat type? or it has to be int? Maybe u can give me little advice what the best solution is.
THX.
Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 5, 2011, 6:48 AM EDT
Please do not forget to mark "Accepted Answer"
albert albertRank #2,683 · 519 reputationPosted Oct 5, 2011, 11:39 AM EDT
Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 5, 2011, 11:46 AM EDT
albert albertRank #2,683 · 519 reputationPosted Oct 5, 2011, 12:23 PM EDT
Liker customers and orders. U put FK in Order , because a customer has an order. That is why I ask u. Or is this not correct?
This is the text:
The complaint data should go in a new table to create containing the following fields:
1. Order number
2. New order number
3. Invoice number
4. Description of complaint
5. Customer contact person
6. Own contact person
7. Resolution description
8. Related suborder
9. Who is responsible multiple choice: Customer service, Billing, Shipping, Printer, Finisher, Prepress, Transport, Sales
10. Amount
11. Status drop down: Open, Approved, Cancelled
12. Date time of complaint
13. Date time closed
14. Complaint assigned to Own contact person
Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 5, 2011, 12:50 PM EDT
albert albertRank #2,683 · 519 reputationPosted Oct 5, 2011, 1:09 PM EDT
Tables:
- Complaint[PK: ComplaintID, FK:ResponsibleID, StatusID ]
- Responsible[PK: ResponsibleID]
- Status[PK:StatusID]
So this is correct?
Prabhu RajaRank #861 · 2.6K reputationPosted Oct 6, 2011, 7:59 AM EDT
Your Query's are looking so good. But i want suggest one thing, Why you can not use GUIDs instead Of Identity's. Because GUID Columns having More Applications then Identity Columns. If you want to know more about GUIDs, you may try this. IDs Vs GUIDs.
Thank You
Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 6, 2011, 8:16 AM EDT
Anythoughts!
Prabhu RajaRank #861 · 2.6K reputationPosted Oct 6, 2011, 8:59 AM EDT
Yes man, you are correct. and i agree with the point "Depends on Application to Application and both having their own advantages and disadvantages".
------------------------------------------------------------------------------------------------------------------------
Thank You, Good Conversation.