dt246813579 2012-08-21 12:51 采纳率: 0%
浏览 77
已采纳

无法使用PDO将值插入MSSQL

I'm using PDO to communicate with my database from PHP code and i have the following code:

$sql = "SELECT <Column> FROM <tablename>";

it works for my mssql database, however when i try to insert some data into it with

$sql = "INSERT INTO <tablename> ( <Column> ) VALUES ( '1' )";

it fails.

why?

it's funny, but when i run that code from my SQL Server Management Studio - it works. I can't get it...

The error i get is:

SQLSTATE[HY000]: General error: 515 General SQL Server error: Check messages from the SQL Server [515] (severity 16) [(null)]

Thanks in advance...

  • 写回答

1条回答 默认 最新

  • douchi2022 2012-08-21 12:54
    关注

    Explanation

    This error occurs at run time when an attempt is made to use a null value while inserting or updating a column that does not allow null values.

    Action

    If this error occurs when you are running an UPDATE or INSERT statement, verify that the data inserted or updated matches the column definition for the affected table.

    Inserting or updating a column does not allow null values.

    Check this: http://www.lcard.ru/~nail/sybase/error/3742.htm or this: http://technet.microsoft.com/en-us/library/aa258724(v=sql.100).aspx

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教