Thread: Designing a database for a windows program

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    17

    Designing a database for a windows program

    Hi,

    I have a guestion about designing a Access database that will be used by a windows program. In my case I'm designing a database that will have information about the loans of a bank has: name and address of customer, start date and maturity date of the loan, amount and interest rate.

    My question is what type of field description should I use in the database. My first choice is to use the Text field description. I don't plan on doing any calculations with the numbers.

    The users of the application will be moving from edit control to edit control typing in the information.

    If I'm just entering text is there any advantage to having the type of information I'm entering match the database field in some way. Example. Should my interest rate be a float and the loan amount be a long?

    Soutine

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    >>Should my interest rate be a float and the loan amount be a long?

    Up to you but IMHO yes.

    This will make it easier to distiguish between data and validate input.

    for example I use ints for database generated ID numbers and longs for all user entered ones.

    When I ask, thru ODBC, what the field type is I can quickly tell how to display it on screen and how validate input.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    17

    Thanks

    Hi N,

    That makes sense. That is what I originally did with the interest rate. I used an edit control to enter the value and then used atof() to store the number in the database.

    The problem I'm now having is using _fcvt() to convert 0.00035 to a string for populating a list control with this value.

    This is the code I have to populate my list control:

    void CTransactionSet::PopulateListControl(CListCtrl *pList)


    //other code left out


    char* bufferBBC;
    int decimal, sign;
    CString strBuyerBrokerCommission;
    CString strValue,strInt,strDecimal;

    strValue = _fcvt(this- >m_BuyerBrokerCommission,6,&decimal, &sign);
    strInt = strValue.Left(decimal);
    strDecimal = strValue.Mid(decimal);


    pList->SetItemText(NextItem,3,strBuyerBrokerCommission );




    The value that shows up in the list control is .350.

    How is it possible to have the value 0.00035 appear in the list control?

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    strBuyerBrokerCommission is used to set the text in the list but never used in the code. So I can't tell you why. Other than that the code looks OK. I do not use _fcvt() and wonder if the CString is correctly converting from the char* to a CString.


    I would use the Format() of the CString

    strValue.Format("%0.6f", this->m_BuyerBrokerCommission );

    for a decimal with leading zeros and 6 digits after the decimal point.

    But I don't know why you want to extract the Left and Right bits so don't know if this will fill your requirements.

    this will though

    BufferBBC = _fcvt(this- >m_BuyerBrokerCommission,6,&decimal, &sign);
    strValue.Format("%s",BufferBBC);
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. program for a database
    By cluez in forum C Programming
    Replies: 1
    Last Post: 03-29-2009, 09:36 PM
  2. Replies: 6
    Last Post: 01-01-2007, 07:36 AM
  3. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 10:00 AM
  4. FlashWindowEx not declared?
    By Aidman in forum Windows Programming
    Replies: 3
    Last Post: 05-17-2003, 02:58 AM
  5. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 12:39 PM