i have column with bit datatype in sql server table(2008).while returing to text box its returning true in text box instead of 1.(VB.Net)
-
2 mai 2012 15:28
i have column with bit datatype in sql server table(2008).while returing to text box its returning true in text box instead of 1.i tried converting it from true to 1 using txtboolvalue.text=Math.abs(CINT(ReturnList.Item(34)).tostring
but it doesnt convert true to 1
secondly
im checking for columns in datatable if there are any nulls.
its checking for nulls in the sqlserver table but its returning true if there is a null.i just want it to return NULL is there is null i textbox..
codeForEachdatacol Indt.Columns
IfNotrow.IsNull(datacol) Then
ReturnList.Add(
CStr(row.Item(datacol).ToString))
'Else : dt.Rows(0).Item(datacol) = DBNull.Value
Else: ReturnList.Add(CStr(row.Item(datacol).ToString = empty))
EndIf
akhila
Toate mesajele
-
2 mai 2012 16:19
Hello sql learner2,
tostring return from boolean value always true, false:
Try this:
Dim b As Boolean = False Dim s As String = If(b, "1", "0")
s contains now "0". with Your code
ReturnList.Add(if(row.Item(datacol), "1", "0")
regards Ellen
Ich benutze/ I'm using VB2008 & VB2010
- Marcat ca răspuns de sql learner12 2 mai 2012 16:21
-
2 mai 2012 16:21Thanks a lot Ellen.it works perfectly :)
akhila
- Editat de sql learner12 2 mai 2012 16:41