Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

binding column of type bit in update query

Posted on 2014-12-06
2
Medium Priority
?
133 Views
Last Modified: 2014-12-06
In this setup, the name column (type is nvarchar(50)) updates just fine.

I cannot get the two other columns (IsFrequentlyUsed & IsActive , both of type bit) will not update.  

I have confirmed that their values are passed in correctly and I have tried to convert them to 1 or 0 as well.  In any case, they do not update.  Is there some consideration for bit type columns in this setup?

$sql = "UPDATE Color 
		SET
		Name =?,
		IsActive = ?,
		IsFrequentlyUsed = ?
		WHERE Id=?";

$params=array( &$Name, &$IsActive,&$IsFrequentlyUsed,&$Idin);

$stmt = sqlsrv_prepare( $conn, $sql, $params, array("Scrollable"=>"buffered"));

if(sqlsrv_execute( $stmt )){

	//query succeeds
	

}else{

	//query failed
	
}

Open in new window

0
Comment
Question by:Zipbang
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 40484797
Using true and false instead of 1 and 0  should work

You can also give more input about a parameter instead of just the value
$params = Array( Array(&$param1, SQLSRV_PARAM_IN, SQLSRV_PHPTYPE_INT, SQLSRV_SQLTYPE_BIT) );Please try that kind of code
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 40484798
No errors?
You may have better results using true/false instead

Or give more input to your parameters like this
$params = Array( Array(&$param1, SQLSRV_PARAM_IN, SQLSRV_PHPTYPE_INT, SQLSRV_SQLTYPE_BIT) );Please try that
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question