Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

how to get the string value of a field of type NUMBER in .mdb database file?

Posted on 2000-02-26
9
Medium Priority
?
193 Views
Last Modified: 2013-11-20
Hi,

in a .mdb database file, there are two fields of type NUMBER, now i want to get the string value of the field, how to do that? also how to get the value of the number directly? that is, if the value is 92, then i wnat to have a int int_var = 92 returned... how to do that?

PLS help me!!! thanks a lot!
0
Comment
Question by:greenbird
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 5

Expert Comment

by:Wyn
ID: 2560752
Depends
what interface you use ?
DAO or plain OBDC ?
0
 
LVL 3

Expert Comment

by:akalmani
ID: 2560753
Hi !!
  I don't know if any function is available for it. But i do have a method

Get the value in int datatype and convert that int to string.

0
 
LVL 1

Expert Comment

by:RAVID
ID: 2560756
Hi,

U can use sscan(char *, "%d",&nInt);
where Char * contains the string whose integer value to be found and nInt is an integer.

Now to get the string value u can connect to the database using DSN and put member variables to them. Now u can use GetWindowText(); and get that value.

Cheers
0
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 
LVL 8

Expert Comment

by:VinExpert
ID: 2560759
HI,

U will get it in the number form easily.
Just say
int Value = UrTablePointer->fieldNamewhichcontains92asvalue;

TO convert it to string I will say

CString l_strVal;
l_strVal.Format("%d", Value);

Then l_strVal, will contain the string converted value.
Try ot out.

VinExpert
0
 

Author Comment

by:greenbird
ID: 2560823
Hi,

well i do not think u had understood my qn, let me state it clearly :)

i use the following to get the the string value of such a field:

COleVariant v1;
char *s1;

v1=rs.GetFieldValue(field_name);
s1=(char *)v1.bstrVal;

however the system always got error, seems it can not get the string value... is it that i shld not use bstrVal? or
.....?

Pls help!
0
 

Accepted Solution

by:
noogie6 earned 10 total points
ID: 2561797
I think you're looking at the wrong field in your variant datatype. It would seem very odd to me that whatever database driver you're using would put a number field from your database into a bstrVal which is for strings. You got two options here. Change your database or convert in your C++ code.

HTH, Noogie
0
 

Expert Comment

by:noogie6
ID: 2561806
Oh, by the way, casting a BSTR to a char * will give you errors too. You need to use a macro for this I think, it's in MSDN somewhere

Noogie
0
 
LVL 3

Expert Comment

by:ghimireniraj
ID: 2563504
get the number value from your .mdb database as integer or BYTE whatever.

int val1;

//suppose your number from
//the database has been retrived in val1

char str_val1[10];
 _itoa(val1,str_val1,10);
MessageBox(str_val1);

//see if str_val1 has what you need

Niraj





0
 

Author Comment

by:greenbird
ID: 2563827
Hi,

well i do not think u understood my qn. what i want is: how to get the integer value or the string value for a field? using COleVariant v1, what is the correct attribute to pass to v1 to get the int value?? (eg, use v1.bstr to get the string value)..

thanks a lot!
0

Featured Post

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question