Setting and Retrieving MySQL BIT(1) datatype as boolean value

N

ng01

What would the proper parameter statement be to insert a true or false
into a MySQL (version 5.1.31) BIT(1) field? Here is what I have:

Cmd.Parameters.Add("@USCurrency", OdbcType.Bit).Value = 0;

And what would be the proper select statement to retrieve a true or
false from that field?
Here is what I'm trying, but it always returns a True (when I browse
the datatable in the debugger):

DataTable dt = GetTable2("select USCurrency from tblquotesnew");

I've tried every OdbcType, with various values, both numeric and
string, to no avail. It always comes back True.

Thanks very much for any ideas.
 
P

Peter Kane

What would the proper parameter statement be to insert a true or false
into a MySQL (version 5.1.31) BIT(1) field? Here is what I have:

Cmd.Parameters.Add("@USCurrency", OdbcType.Bit).Value = 0;

And what would be the proper select statement to retrieve a true or
false from that field?
Here is what I'm trying, but it always returns a True (when I browse
the datatable in the debugger):

DataTable dt = GetTable2("select USCurrency from tblquotesnew");

I've tried every OdbcType, with various values, both numeric and
string, to no avail. It always comes back True.

Thanks very much for any ideas.


Try DataTable dt = GetTable2("select USCurrency from tblquotesnew where
USCurrency = 1");
 
P

Peter Kane

What would the proper parameter statement be to insert a true or false
into a MySQL (version 5.1.31) BIT(1) field? Here is what I have:

Cmd.Parameters.Add("@USCurrency", OdbcType.Bit).Value = 0;

And what would be the proper select statement to retrieve a true or
false from that field?
Here is what I'm trying, but it always returns a True (when I browse
the datatable in the debugger):

DataTable dt = GetTable2("select USCurrency from tblquotesnew");

I've tried every OdbcType, with various values, both numeric and
string, to no avail. It always comes back True.

Thanks very much for any ideas.
Hi there , I received your email ( you really should reply to the
newsgroup ) I don't know about MySQL, but in SQL server you can say
something along the lines of ( in your select statement ) : myfield =
Case USCurrency = 0 Then "N" Else "Y"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top