Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Pinto
Aged Yak Warrior
590 Posts |
Posted - 2005-01-13 : 11:30:58
|
| I have imported a large Access table into SQL Server. One of the fields is a bit field, but the Access table has a large number of nulls in this field so when I try to display the data in bound text boxes on my web page I am getting the error 'Cast from type 'DBNull' to type 'Boolean' is not valid for those records with null and not 1How can I get round this other than running an update query on my sql table to replace the nulls with 0I am using asp.net |
|
|
jhermiz
3564 Posts |
Posted - 2005-01-13 : 11:31:57
|
quote: Originally posted by Pinto I have imported a large Access table into SQL Server. One of the fields is a bit field, but the Access table has a large number of nulls in this field so when I try to display the data in bound text boxes on my web page I am getting the error 'Cast from type 'DBNull' to type 'Boolean' is not valid for those records with null and not 1How can I get round this other than running an update query on my sql table to replace the nulls with 0I am using asp.net
just write code to check if it is null ?And handle the result appropriately... Keeping the web experience alive -- [url]http://www.web-impulse.com[/url] |
 |
|
|
Pinto
Aged Yak Warrior
590 Posts |
Posted - 2005-01-14 : 09:58:53
|
| I fill a dataset and my textboxes are bound so they automatically fill. How do I then code to cope with the null ? |
 |
|
|
DustinMichaels
Constraint Violating Yak Guru
464 Posts |
Posted - 2005-01-14 : 10:36:34
|
| You can check to see if something is null by doing something like this.I'm guessing your using VB.NETIf Convert.IsDbNull = record("Your Boolean Column") Then Use a value of 0Else Use value from your recordDustin Michaels |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-01-14 : 12:42:37
|
or if you can live with it then do in your sqlselect coalesce(col1, '') ...from ...Go with the flow & have fun! Else fight the flow |
 |
|
|
JimL
SQL Slinging Yak Ranger
1537 Posts |
Posted - 2005-01-14 : 14:28:52
|
| Or use a SP and isnull to build your page.Select Isnull(yourcolumn,0)from yourtableJimUsers <> Logic |
 |
|
|
|
|
|