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 孟德尔随机化怎样画共定位分析图
  • ¥18 模拟电路问题解答有偿
  • ¥15 Matlab在app上输入带有矩阵形式的初始条件发生错误
  • ¥15 CST仿真别人的模型结果仿真结果S参数完全不对
  • ¥15 误删注册表文件致win10无法开启
  • ¥15 请问在阿里云服务器中怎么利用数据库制作网站
  • ¥60 ESP32怎么烧录自启动程序
  • ¥50 html2canvas超出滚动条不显示
  • ¥15 java业务性能问题求解(sql,业务设计相关)
  • ¥15 52810 尾椎c三个a 写蓝牙地址