converting a varchar datatype to a bit data type using VBScript
-
Hi, I have a ASP form which has a radio control for "yes/no", and in the SQL server I have a data type bit to store the value, but before inserting the values, how to I convert the value "yes and no" to bit data type. Thanks, abhi abhi
-
Hi, I have a ASP form which has a radio control for "yes/no", and in the SQL server I have a data type bit to store the value, but before inserting the values, how to I convert the value "yes and no" to bit data type. Thanks, abhi abhi
Converting a yes/no to a bit.... Enum MyBool YES = 0 NO = 1 End Enum dim bValue as byte bValue = Convert.ToByte(MyBool.YES) Or you could use this method I put together for converting strings Public Sub ConvertStringByte(ByVal stringVal As String) ' Convert the string to a char array Dim chArray() As Char chArray = stringVal.ToCharArray(0, stringVal.Length) 'Convert each char into a byte Dim i As Short Dim b As Byte Dim byArray(stringVal.Length) As Byte For i = 0 To chArray.Length - 1 b = System.Convert.ToByte(chArray(i)) byArray(i) = b Next 'Write each value out and the entire bytes For i = 0 To byArray.Length - 1 Console.Write(byArray(i).ToString() & ":") Next 'Reconstruct the string value and print it For i = 0 To byArray.Length - 1 Console.Write(Convert.ToChar(byArray(i))) Next End Sub