Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/157.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server SQL Server:插入查询时出错_Sql Server_Pdo - Fatal编程技术网

Sql server SQL Server:插入查询时出错

Sql server SQL Server:插入查询时出错,sql-server,pdo,Sql Server,Pdo,我对SQL Server列报价编号有一个问题,该编号不能接受超过5位数字。5位或以下工作正常,但超过5位则会导致错误: xx.xx.xx.xx没有发送任何数据。 错误\u空\u响应 示例-报价编号12345工作正常,但123456导致错误 我还在查询中将bindParam更改为bindValue,但没有更改结果 连接: try { $proconn = new PDO("dblib:host=$servername;dbname=TableQuote;charset=UTF-8", $u

我对SQL Server列报价编号有一个问题,该编号不能接受超过5位数字。5位或以下工作正常,但超过5位则会导致错误:

xx.xx.xx.xx没有发送任何数据。
错误\u空\u响应

示例-报价编号
12345
工作正常,但
123456
导致错误

我还在查询中将bindParam更改为bindValue,但没有更改结果

连接

try {
    $proconn = new PDO("dblib:host=$servername;dbname=TableQuote;charset=UTF-8", $username, $password);

    // set the PDO error mode to exception
    $proconn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e)
{
    echo "Connection failed" . $e->getMessage;
}
可变数据:

//$quote_number="123456";
[quote_noumber] => '12345'
[inside_sales] => 'Pat Zerphy'
[outside_sales] => 'SEL102'
[customer_code] => 'SEL101'
[custome_name] => 'Selex Systems Inegrations'
[customer_contact] => 'Bob Smith'
[quote_details] => 'Misc coax cable assemblies.
1/2" Superflex, 1/4" Superflex'
[rna_location] => '1'
[number_of_line_items] => '25'
[created] => '1468291705'
插入查询:

try {
    $prosql = $proconn->prepare("insert into dbo.QuoteRecord(quote_number,customer_code,customer_name,rna_location,inside_sale,outside_sale,customer_contact,quote_detail,number_of_line_items,created)VALUES(:quote_number,:customer_code,:customer_name,:rna_location,:inside_sale,:outside_sale,:customer_contact,:quote_detail,:number_of_line_items,:created)");

    $prosql->bindParam(':quote_number',$quote_number);
    $prosql->bindParam(':customer_code',$customer_code);
    $prosql->bindParam(':customer_name',$customer_name);
    $prosql->bindParam(':rna_location',$rna_location);
    $prosql->bindParam(':inside_sale',$inside_sale);
    $prosql->bindParam(':outside_sale',$outside_sale);
    $prosql->bindParam(':customer_contact',$customer_contact);
    $prosql->bindParam(':quote_detail',$quote_detail);
    $prosql->bindParam(':number_of_line_items',$number_of_line_items);
    $prosql->bindParam(':created',$created);

    $prosql->execute();
}
catch ( PDOException $e ) {
    print( "Error connecting to SQL Server." );
    die(print_r($e));
}
数据类型:

Array
(
    [TABLE_CATALOG] => TableQuote
    [0] => proALPHA
    [TABLE_SCHEMA] => dbo
    [1] => dbo
    [TABLE_NAME] => QuoteRecord
    [2] => QuoteRecord
    [COLUMN_NAME] => quote_number
    [3] => quote_number
    [ORDINAL_POSITION] => 2
    [4] => 2
    [COLUMN_DEFAULT] => 
    [5] => 
    [IS_NULLABLE] => YES
    [6] => YES
    [DATA_TYPE] => varchar
    [7] => varchar
    [CHARACTER_MAXIMUM_LENGTH] => 128
    [8] => 128
    [CHARACTER_OCTET_LENGTH] => 128
    [9] => 128
    [NUMERIC_PRECISION] => 
    [10] => 
    [NUMERIC_PRECISION_RADIX] => 
    [11] => 
    [NUMERIC_SCALE] => 
    [12] => 
    [DATETIME_PRECISION] => 
    [13] => 
    [CHARACTER_SET_CATALOG] => 
    [14] => 
    [CHARACTER_SET_SCHEMA] => 
    [15] => 
    [CHARACTER_SET_NAME] => iso_1
    [16] => iso_1
    [COLLATION_CATALOG] => 
    [17] => 
    [COLLATION_SCHEMA] => 
    [18] => 
    [COLLATION_NAME] => SQL_Latin1_General_CP1_CI_AS
    [19] => SQL_Latin1_General_CP1_CI_AS
    [DOMAIN_CATALOG] => 
    [20] => 
    [DOMAIN_SCHEMA] => 
    [21] => 
    [DOMAIN_NAME] => 
    [22] => 
)
示例-报价编号-12345工作正常,但123456给出 错误

如果是这种情况,那么很可能是因为列
quote\u number
的列大小定义。看起来它是一个
VARCHAR
列,如果它仍然没有错,您可能已经将其大小设置为
VARCHAR(5)


发布
dbo.QuoteRecord
table的表定义或模式。

顺便说一句,您得到的错误是什么?您可能有尚未发布的必要反馈,或者您可能应该运行一些测试。比如违反约束?插入无效的数据类型?无效连接等。因为SQL Server提供了很好的反馈,如果您能够得到的话。