| |

VerySource

 Forgot password?
 Register
Search
View: 848|Reply: 6

How to get float or int data in the database with ADO?

[Copy link]

2

Threads

5

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-1-7 01:00:01
| Show all posts |Read mode
Guys, all I see is getting text,
For example: var = m_pRecordset-> GetCollect ("Name");
if (var.vt! = VT_NULL)
strName = (LPCSTR) _bstr_t (var);

How do you get float or int data?
Thank you, I'm not too familiar with ADO
Reply

Use magic Report

0

Threads

30

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

Post time: 2020-1-7 09:09:01
| Show all posts
_variant_t var = m_pRecordset-> GetCollect ("int_field") ;;
if (var.vt == VT_I4) int i = var.intVal;
if (var.vt == VT_R4) float f = var.fltVal;
Reply

Use magic Report

2

Threads

5

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-1-7 09:30:01
| Show all posts
Thank you
Could explain: _variant_t var
VT_I4
VT_R4
What does it all mean?
Thank you
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-7 09:33:01
| Show all posts
Positive solution upstairs, if you add an else between the two if, it will be judged less once, and the efficiency will be a little bit ^^
Reply

Use magic Report

0

Threads

55

Posts

32.00

Credits

Newbie

Rank: 1

Credits
32.00

 China

Post time: 2020-1-11 01:18:01
| Show all posts
_variant_t is the data structure:
VT_I4
VT_R4
Is the data type among them.
Reply

Use magic Report

2

Threads

5

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-2-21 16:30:01
| Show all posts
flot mvalue;
var = m_pRecordset-> GetCollect ("dometic_soil");
 if (var.vt == VT_R4)
  mvalue = var.fltVal;

dometic_soil is single precision in the database.
But why isn't the value in the above code a value in the database?
What went wrong? Please advise
Reply

Use magic Report

0

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-2-22 10:30:02
| Show all posts
You can use atoi ((LPCTSTR) (_ bstr_t) m_pRecordset-> GetCollect ("field"));
atol (), atof () ...
VT_I4 -------- 32bit integer
VT_R4 -------- 32bit floating point number
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list