Solved

binding column of type bit in update query

Posted on 2014-12-06
2
121 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
  • 2
2 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 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 142

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This article discusses four methods for overlaying images in a container on a web page
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

747 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now