不能將值 NULL 插入列 'id',表 'weibo.dbo.myfriend';列不允許有空值。INSERT 失敗。

來源:互聯網
上載者:User

    使用SQL Server 2005 資料庫做web的項目出現 :不能將值 NULL 插入列 'id',表 'weibo.dbo.myfriend';列不允許有空值。INSERT 失敗。

     錯誤提示:

com.microsoft.sqlserver.jdbc.SQLServerException:

      at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(Unknown Source)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate(Unknown Source)

     錯誤原因:

                  在SQL Server 2005中建立myfriend是沒有將id標示設定為"是"

     解決辦法:

如 將其Id設定為"是"

                

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.