Agent909
asked on
What is the syntax for saving a boolean value into SQLEXPRESS 2008?
I have a column in several tables called InUse. The value is set to True if a user is editing that record. I have tried many ways to save it, but none of them have worked. This is the code I have now. The zero at the end is for my InUse field, which in this case I'm trying to get it to save as False, which is what the value of obj4.InUse is. Can you help? This doesn't work.
mySQL = "INSERT INTO Users " & _
"(UserID,LoginName,Passwor d,Last,Fir st,Email,P hone) " & _
"VALUES (" & _
"'" & obj4.UserID & "'," & _
"'" & obj4.LoginName & "'," & _
"'" & obj4.Password & "'," & _
"'" & obj4.Last & "'," & _
"'" & obj4.First & "'," & _
"'" & obj4.Email & "'," & _
"'" & obj4.Phone & "'," & _
" 0);"
mySQL = "INSERT INTO Users " & _
"(UserID,LoginName,Passwor
"VALUES (" & _
"'" & obj4.UserID & "'," & _
"'" & obj4.LoginName & "'," & _
"'" & obj4.Password & "'," & _
"'" & obj4.Last & "'," & _
"'" & obj4.First & "'," & _
"'" & obj4.Email & "'," & _
"'" & obj4.Phone & "'," & _
" 0);"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I just got this to work. I forgot to add "UserID" after Phone on the second like. Duh! thanks anyway!
ASKER
We must've figured it out at about the same time. I will award you the points. I may have another question in a while. Thanks again!
Hello Agent909,
You should use the "bit" datatype : http://msdn.microsoft.com/en-us/library/aa258271(SQL.80).aspx
And CAST : http://msdn.microsoft.com/en-us/library/ms187928.aspx
CAST('true' AS BIT) return 1
CAST('false' AS BIT) return 1
Regards.
You should use the "bit" datatype : http://msdn.microsoft.com/en-us/library/aa258271(SQL.80).aspx
And CAST : http://msdn.microsoft.com/en-us/library/ms187928.aspx
CAST('true' AS BIT) return 1
CAST('false' AS BIT) return 1
Regards.
mySQL = "INSERT INTO Users " & _
"(UserID,LoginName,Password,Last,First,Email,Phone) " & _
"VALUES (" & _
"'" & CAST(obj4.UserID AS BIT) & "'," & _
"'" & CAST(obj4.LoginName AS BIT) & "'," & _
"'" & CAST(obj4.Password AS BIT) & "'," & _
"'" & CAST(obj4.Last AS BIT) & "'," & _
"'" & CAST(obj4.First AS BIT) & "'," & _
"'" & CAST(obj4.Email AS BIT) & "'," & _
"'" & CAST(obj4.Phone AS BIT) & "'," & _
" 0);"
mySQL = "INSERT INTO Users " & _
"(UserID,LoginName,Passwor
"VALUES (" & _
"'" & obj4.UserID & "'," & _
"'" & obj4.LoginName & "'," & _
"'" & obj4.Password & "'," & _
"'" & obj4.Last & "'," & _
"'" & obj4.First & "'," & _
"'" & obj4.Email & "'," & _
"'" & obj4.Phone & "'," & _
" 0);"