Got error after Post an Ad - classifieds Starter Kit

Discussion in 'ASP.NET Starter Kits' started by cabplacecom, Jun 30, 2007.

  1. Please help!
    </o:p>
    My classifieds site is working, but I always get an error when I finished ?Post an Ad?:
    ?Cannot insert the value NULL into column 'Id', table 'SQL2005_374085_cabplace.dbo.classifieds_Ads'; column does not allow nulls. INSERT fails.
    The statement has been terminated.?</o:p>

    (P.S I tried ?Post an Ad? on my local server, it works.) </o:p>
    Is that because I only added one SQL 2005 database to my hosting account and I put ?App_Data (including aspnetdb and classifiedsdb) to this one database? Do I have to add two databases to my hosting account? Is that possible to put all tables of aspnetdb and classifiedsdb to one database?</o:p>
    Thanks</o:p>
    Daping</o:p>
     
  2. You can have both the database schema's created on a single database and you dont need two seperate databases for this.I recommend you to re upload your code.I believe 'ID' specified in the error is the primary key of the table 'classifieds_Ads',hence cannot be nul..For some reason,your code is trying to insert a null value for this field,which is offcourse not valid.I dont think there is an issue with your database.

    Vikram

    DiscountASP.NET
    www.DiscountASP.NET
     
  3. one more thing: the website was working good on local server, but the sameerror came even still on local serverafter I modified web.config file.



    Server Error in '/' Application.


    Cannot insert the value NULL into column 'Id', table 'SQL2005_374085_cabplace.dbo.classifieds_Ads'; column does not allow nulls. INSERT fails.
    The statement has been terminated.



    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Data.SqlClient.SqlException: Cannot insert the value NULL into column 'Id', table 'SQL2005_374085_cabplace.dbo.classifieds_Ads'; column does not allow nulls. INSERT fails.
    The statement has been terminated.

    Source Error:





    Code:
    Line 2055:            Dim returnValue As Object
    Line 2056:            Try 
    Line 2057:                returnValue = command.ExecuteScalar
    Line 2058:            Finally
    Line 2059:                If (previousConnectionState = System.Data.ConnectionState.Closed) Then
    Source File: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\18e5e621\f57cf16c\App_Code.otrt6_ud.5.vb Line: 2057
    ... ...
     
  4. This error shows that you are passing a null value to your database. The table or column you are trying to insert it to does not allow nulls. You will either need to make sure the value you are passing is not a null value and that it has the right data type as the table or you can set the table/column to allow null values. This will be up to on how your database is setup and what the requirements of your web application will be.
     
  5. AfterI registered an newuser, I can see an new record in Aspnetdb, but I cannot see new record in Classifiedsdb! What's that problem?
     
  6. For Classifieds Starter Kit, when a new user has been created, an ID number (primary key) should be produced in database automatically, but it failed, which causes that error came. I just don?t know why an ID number can be produced in local database automatically, but can?t be produced in hosting database automatically? Must be somewhere the codes have to be changed? Because the new user can be recorded in ?aspnetdb? database, but not in ??classifieddb? database.
     

Share This Page