How to Synchronize VB.NET Data Type at Database Data Type ?

witecloner

Well-known member
Joined
Feb 12, 2009
Messages
45
Programming Experience
Beginner
Hi all, i am newbie in vb.net.
I have two problem in difference case need to solved,

First case is i have try to build simple program. Where that's program is simplified to manage customer database.

Ok, before i want to describe first my simple database design. This customer table have some columns that are :
VB.NET:
CustomerCode (int) PK,
CustomerName(varchar),
CustomerAddress(varchar),
Discount(decimal)
Deposit(money)

my problem is :
How can i save discount field and deposit field with 2 precisions digits into my table. I mean is save discount textbox value and deposit textbox value to database. Example :
TextBoxDiscount Value is 5.00 , Stored value to database is also same with TextBoxDiscount Value and proper to Discount Column's Data Type.
TextBoxDeposit Value is 1.500.000,00, Stored value to database is also same with TextBoxDeposit and proper to Deposit Column's Data Type.

And, The second case is how can i match Datetime Data Type in SQL Server 2005 with DateTimePicker Value in my project (code in vb.net)?


Thank you :D
 
Start by reading the DW2 link in my signature, section on Creating a Simple Data App

It answers your question 2 in so far as: you don't have to. Visual Studio does the matching for you. Note that it may be best to investigate using something like NullableDateTimePicker because the standard DTP doesnt do nulls very well (but then again, maybe neither does your database)


In answer to your question 1, "How do I save a valu of 5.00 in a decimal column"
You don't; you save 5, because 5.00 is the same as 5
When you come to display the data you use a component that is geared up for numbers, such as numeric updown, or you format it into a string "5.00" when you read it from the db. In oracle that would be:

SELECT to_char(discount, '990.00') as discount FROM myTable

I'm not sure what this would be in your DB, but there is a dedicated forum (or google) for that
 
Yeah you're right Cjard. I have read some tutorial on google. It said just manipulate my data when i showing that value. Thank you for your answer.

Oh yeah do you know how to set money data type precision to only 2 digits decimal place(for default it save in 4 digits decimal place) ?

And also one more again :p hehehehe, i don't know what meaning of timestamp data type, and what is used for. Could you tell me?

Oh yeah sir, if you do not mind, may I request you to keep all articles in the form to the rar files? my network connection is very slow. please...

Thank you
 
Last edited:
Yeah you're right Cjard. I have read some tutorial on google. It said just manipulate my data when i showing that value. Thank you for your answer.

Oh yeah do you know how to set money data type precision to only 2 digits decimal place(for default it save in 4 digits decimal place) ?
To format it in VB.NET you'd call .ToString("0.00") on it. Also:

string.Format("Price was {0:0.00}, now {1:0.00}", oldPrice, newPrice)

And also one more again :p hehehehe, i don't know what meaning of timestamp data type, and what is used for. Could you tell me?
In oracle it's a high precision date and time



The forum doesnt allow rar, I think.. I usually use zip
 
okay, zip file is no problem too. Please upload it. Hope you want to upload it as soon as possible. Once again thank you very much. :D

It's very hard for me to build a Trade Management System Program...:(
Have you a YM account, maybe we will talk directly use YM. Thank you
 
Erm... What did I say I'd upload?


And as for any kind of IM; I don't use them - I don't even use SMS - way too busy, sorry
 
Em...if you didn't say it, could you to compress it and upload it to this forum?please...i'm very need it...thank you...:D
 
If yure looking for someone to do your work for you, you need to visit rentacoder, getafreelancer or something like that
 

Latest posts

Back
Top