Last post Nov 17, 2008 09:55 PM by darkknight187
Feb 14, 2007 05:07 PM|lorenzonunez|LINK
this error is givin' me someone knows why.... thanks.
Feb 15, 2007 01:14 AM|MIB426|LINK
Hi, just like error said
you are inserting data which conflict in the table members' column Id
so lets said you have TableA and TableB
TableA has FieldA1 and FieldA2 (FieldA1 is primary key)
TableB has FieldB1 and FieldA1 (FieldB1 is primary key, FieldA1 is foreign key of TableA.FieldA1)
when you insert record into TableB, INSERT TableB(FieldB1, FieldA1) VALUES('B', 'BB")
your "BB" must also in TableA's FieldA1 otherwise it will have foreign key exception
Jun 24, 2008 02:41 AM|intechspecial|LINK
Your reply does help to resolve the error, but does not completely help for a novice like myself.
Let me expand a little on the issue in "Lamens terms".
We are using the Classifieds ASP.net starter kit download.
It installed correctly, everything worked as it should, until you try and post an ad through the web site.
Logged in as administrator, post an ad and after submittin ad to database I get the following error:
Line 2176: Dim returnValue As Object
Line 2177: Try
Line 2178: returnValue = command.ExecuteScalar
Line 2179: Finally
Line 2180: If (previousConnectionState = Global.System.Data.ConnectionState.Closed) Then
Line 2176: Dim returnValue As Object
Source File: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\classifieds1\f01aba27\898b6ba\App_Code.onnirgac.16.vb Line:
Obviously there is a relationship between the two tables, as the error stated. So I am understanding correctly that the error is being listed because(using your example) there is a relationship from Table A.FieldA1 to Table B.FieldA1 that is tied via a foreign
key constraint in Table B. But this relation is not reflected back to Table A.FieldA1 when data is inserted into Table B.FieldA1.
So the only way that Table B.FieldA1 can be updated is if Table A.FieldA1 is changed. Table B.FieldA1 is only a reflection of TableA.FieldA1.
So the problems is in the way the application is set. It is set to make changes to Table B.FieldA1 when you try to update a table via the web application.
So if Table"dbo.Member"s = Table A,
and Column 'Id' = .FieldA1 then the issue is with the insert statement itself. So the insert statement is pointing to the wrong table to udpate? After more careful review of the tables and there foreign keys, I have found that I am
To further complicate things, I redid the error and got an error box attached to the line of code above:Yellow exclamation point: SqlExcpetion was unhandled by user code was at the top of the window. I clicked on view detail and another window popped up
that had an error code: ErrorCode -2146232060
I looked up the error code and it stated that the code was caused by a connection string, which is not possible as I was connected to the database the entire time.
So......back to designing html websites, and following some more tutorials on asp.net or learnvisualstudio.net.
In the meantime if anyone out there in has worked with this problem AND with the Classifieds Starter Kit, please assist.
Classified Starter Kit Error Foreign Key Constraint Error "FK_Ads_Members
Aug 20, 2008 04:27 AM|intechspecial|LINK
The error is actually a relatively simple error.
When a user is created through asp.net administration, the members table is not automatically updated.
The asp.net administration should be used for admin purposes only.
Really was not as difficult of an error as I had originally thought.
Nov 11, 2008 11:48 AM|araujolima|LINK
i am facing the same problem: i am the admnistrator and everything works properly before and after i hosted my website, i can post ad, remove ad, etc....but when try to register with another user i ca't post ad....i see the same. How can I fix it?
The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Ads_Members". The conflict occurred in database "BREVI", table "dbo.Members", column 'Id'.
The statement has been terminated
Linha 2188: Dim returnValue As Object
Linha 2189: Try
Linha 2190: returnValue = command.ExecuteScalar
Linha 2191: Finally
Linha 2192: If (previousConnectionState = Global.System.Data.ConnectionState.Closed) Then
Nov 11, 2008 02:18 PM|intechspecial|LINK
I am not sure what the exact cause of the error is.
I do know if you ad and remove users via the web.config file(asp website administration), the tables will not update the user.
You will need to add users directly through the website itself.
Nov 13, 2008 12:38 PM|araujolima|LINK
Do you know if this error happen only for one database? If i set up two database as original file new user will be able to post ad when i host the web site?
Nov 13, 2008 05:53 PM|intechspecial|LINK
I probably have less experience with asp.net and SQL then you guys do.
After days and days and days of trying to figure this out I found that the error only happened when you added/removed users via the web.config file via the administration page.
This program is set to run via the database, and any changes in the web.config file have absolutely no bearing on the database because they do not seem to be connected.
I am not sure what you mean by adding a second database, and I am not sure that I am able even qualfied to answer your question.
My understanding is that their is not a need for a second database, as it runs great as it is.
One thing to realize as well is that you are using a SQL Express connection string, and most hosting companies to not approve or allow SQL Express Edition, you must use SQL Standard or better.
THe best and easiest way I have found you can set up a starter kit, is to find hosting companies that offer "ASP.net Starter Kit Hosting". Google this and you will cut out hours upon hours of work. Some hosting companies make it as easy as a "1 click install"
for the starter kit, and all you would have to do is make changes to the CSS.
I hope this helps, and I am open to collaborating with anyone and everyone via email or phone.
Nov 14, 2008 05:56 AM|araujolima|LINK
Thanks for your help!
But I have one doubt when do you said that this "error only happened when you added/removed users via the web.config file via the administration page"
I do not know if it means that i have to add or remove users only by ASP.NET Configuration page or I should not add any user before host the website and after that i can add user.
Nov 14, 2008 08:22 AM|intechspecial|LINK
DO NOT add users by the ASP.NET configuration page, as this is causing the error. Only use your websites host to make changes to users(http://www.StarterKitWebsite.com) If you do use the ASP.net Configuration
page to add or remove users, you will have to make appropriate additions & removals to database as well.
To make things easier on yourself, use the Starter Kit locally on your machine ONLY to make changes to the design(Cascading Style Sheets). Do not make changes to users, type of classifieds, etc.
Google the following term: "asp.net Starter Kit web hosting". An example of a site that offers an easy to use "one click installation" of a starter kit is:
http://www.appliedi.net/starter-kits/ Install a classifieds starter kit, add and remove users via online website, make changes to CSS on you machine(locally), and upload style sheets.
Really should be as easy as designing an css/html website.
Nov 17, 2008 08:39 AM|araujolima|LINK
I have downloaded again the started kit and hosted it but did not make any change in web site until now. I created a database at a host with database publish wizard and how can I create a user as administrator without go to ASP.net Configuration page?
Nov 17, 2008 01:47 PM|intechspecial|LINK
Create a user like you usually would in the admin page.
You will then need to MANUALLY add the user information to the corresponding tables in the database.
Nov 17, 2008 02:51 PM|araujolima|LINK
how can i do that?
many thanks for your help
Nov 17, 2008 09:55 PM|darkknight187|LINK
It's pretty easy.
All you have to do is go here:
http://forums.asp.net/t/1110595.aspx the link for the users.aspx file is at the bottom of the first post.
It's written in C# and I primarily use VB and it still works fine, so no need to change anything with it.
Create a normal login Id through your website,
Upload the file to your website, and place it on in your main folder such as:
Enter the location of the users file into your browser, and set your Id as administrator.
Then VERY IMPORTANT, move the users.aspx file to a protected area, such as the Admin folder.
And just like that, you're done.