vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| OK. I don't recall having a problem with this before, but, how do I assign a variable to a MySQL Bit field? I'm trying to set up a CheckBox that is on my form, and I've tried variations of the following: FirstTime.Checked = CBool(RS("FirstTime")) FirstTime.Checked = CBool(RS("FirstTime").ToString) FirstTime.Checked = RS("FirstTime") FirstTime.Checked = Convert.ToBoolean(RS("FirstTime")) I believe that all of them give the error, "String was not recognized as a valid Boolean". When I view the field value in SQL Manager 2005 Lite, It presents a check box for the field value. When I view it through the MySQL Query Browser, it presents the value as b'1' Any hints? I'm sure this is a basic issue, but I just can't seem to find a way to do it. Thanks, Jesse |
| ||||
| Since no one seemed able to answer my question, I went looking elsewhere, and found the solution. Just wanted to share with you, in case anyone else is having the problem. I realize now (too late), that I should have posted this on the MySQL .NET list. I'm sure someone would have answered there. Anyway... Apparently, MySQL Stores a BIT value as a character. Chr(0) = False, and Chr(1) = True. Once I discovered this, I was easily able to do a FirstTime.Checked = (RS("FirstTime") = Chr(1)), and it worked perfectly. Jesse ----- Original Message ----- From: "Jesse" <jlc@msdlg.com> To: "MySQL List" <mysql@lists.mysql.com> Sent: Wednesday, January 17, 2007 5:23 PM Subject: ASP.NET Access to MySQL BIT field????-Help > OK. I don't recall having a problem with this before, but, how do I > assign > a variable to a MySQL Bit field? I'm trying to set up a CheckBox that is > on > my form, and I've tried variations of the following: > > FirstTime.Checked = CBool(RS("FirstTime")) > FirstTime.Checked = CBool(RS("FirstTime").ToString) > FirstTime.Checked = RS("FirstTime") > FirstTime.Checked = Convert.ToBoolean(RS("FirstTime")) > > I believe that all of them give the error, "String was not recognized as a > valid Boolean". When I view the field value in SQL Manager 2005 Lite, It > presents a check box for the field value. When I view it through the > MySQL > Query Browser, it presents the value as b'1' > > Any hints? I'm sure this is a basic issue, but I just can't seem to find > a > way to do it. > > Thanks, > Jesse > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: http://lists.mysql.com/mysql?unsub=jlc@msdlg.com > > |