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 ShaikhPosted Oct 5, 2011, 5:11 PM
Prabhu RajaPosted Oct 6, 2011, 12:59 PM
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.
Javeed M ShaikhPosted Oct 6, 2011, 12:16 PM
Anythoughts!
Prabhu RajaPosted Oct 6, 2011, 11:59 AM
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
albert albertPosted Oct 5, 2011, 5:09 PM
Tables:
- Complaint[PK: ComplaintID, FK:ResponsibleID, StatusID ]
- Responsible[PK: ResponsibleID]
- Status[PK:StatusID]
So this is correct?
Javeed M ShaikhPosted Oct 5, 2011, 4:50 PM
albert albertPosted Oct 5, 2011, 4:23 PM
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 ShaikhPosted Oct 5, 2011, 3:46 PM
albert albertPosted Oct 5, 2011, 3:39 PM
Javeed M ShaikhPosted Oct 5, 2011, 10:48 AM
Please do not forget to mark "Accepted Answer"
albert albertPosted Oct 5, 2011, 3:08 AM
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 ShaikhPosted Oct 4, 2011, 11:32 AM
General Algo:
Open Connection
Create Command
Assign Parameters (if you have stored procedure)
Execute Command (give your SQL)
Close Connection
Dispose
albert albertPosted Oct 4, 2011, 11:15 AM
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 ShaikhPosted Oct 4, 2011, 10:28 AM
Please do not forget to mark "Accepted Answer".
albert albertPosted Oct 4, 2011, 10:24 AM
albert albertPosted Oct 4, 2011, 10:21 AM
Javeed M ShaikhPosted Oct 4, 2011, 10:15 AM
Please do not forget to mark "Accepted Answer".
albert albertPosted Oct 4, 2011, 10:14 AM
Javeed M ShaikhPosted Oct 4, 2011, 10:10 AM
Please do not forget to mark "Accepted Answer".
albert albertPosted Oct 4, 2011, 10:04 AM
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 ShaikhPosted Oct 4, 2011, 9:43 AM
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"