473,467 Members | 1,432 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Defining data types for fields, when you a create a file

Hi All,

When I create fields (in files) I need assign a data type like char,
varchar, money etc.

I have some questions about the data types when you create fields in a
file.

What is the difference between data type 'CHAR' and 'TEXT'?
When do you use 'VAR' in your datatype word? e.g. VARCHAR ?
What is the difference 'NVARCHAR' & 'VARCHAR' & 'CHAR'?
What is the 'N' in 'VARCHAR'?

Let's say I would like to create a file see below for the fields.
What data type do you assign for it? Can someone help me assigning data
types?

File1
======
Name data type?
Address data type?
City data type?
Salary Amount (2 decimal) data type?
Age data type?
Gender (value M/F) data type?
length (2 decimal) data type?
Quantity ( 0 decimal) data type?
Cost price (4 decimal) data type?
Extented price ( 2 decimal) data type?
Birth Date data type?
User id data type?
Time entered data type?
Thank you clarifying these datatypes.

Regards,

Mesut

Mar 9 '06 #1
11 3409
"mesut demir" <me*********@noveonbe.com> schrieb im Newsbeitrag
news:11*********************@i39g2000cwa.googlegro ups.com...
Hi All,

When I create fields (in files) I need assign a data type like char,
varchar, money etc.

I have some questions about the data types when you create fields in a
file.

What is the difference between data type 'CHAR' and 'TEXT'?
When do you use 'VAR' in your datatype word? e.g. VARCHAR ?
What is the difference 'NVARCHAR' & 'VARCHAR' & 'CHAR'?
What is the 'N' in 'VARCHAR'?
These are names of data types used in databases. In VB.Net we have other
data types, like String, Integer etc. Why do you refer to the database data
types if you want to store something in a file? That can be right - just
asking.

To get an explanation of the data types, look at the documentation of the
database. For SQL Server:
http://msdn.microsoft.com/library/en...da-db_7msw.asp

Mapped data types:
http://msdn.microsoft.com/library/en...kdatatypes.asp

Let's say I would like to create a file see below for the fields.
What data type do you assign for it? Can someone help me assigning data
types?

File1
======
Name data type?
Address data type?
City data type?
Salary Amount (2 decimal) data type?
Age data type?
Gender (value M/F) data type?
length (2 decimal) data type?
Quantity ( 0 decimal) data type?
Cost price (4 decimal) data type?
Extented price ( 2 decimal) data type?
Birth Date data type?
User id data type?
Time entered data type?
Thank you clarifying these datatypes.

http://msdn.microsoft.com/library/en...nDataTypes.asp

http://msdn.microsoft.com/library/en...asslibrary.asp

(Below head line "System Namespace", some basic data types are listed)
Armin

Mar 9 '06 #2
Hi Armin,

Thank you for repsonse. I learnt more from your links you sent. But I
would like to create a file and I create some fields. I need to assign
data types to that fields. My problem is which data type do I assign to
the fields.
e.g. I create a file and the file has a field "NAME" 50 positions.
Okay what should be the DATA type for this in is it CHAR or VARCHAR or
NVARCHAR or NVAR or TEXT or NTEXT ?????....

For that reason I have created a file BELOW but what should be the data
type of these fields below
Can you help me with that ? From there I can learn...

TESTFILE:
--------------
Name data type?
Address data type?
City data type?
Salary Amount (2 decimal) data type?
Age data type?
Gender (value M/F) data type?
length (2 decimal) data type?
Quantity ( 0 decimal) data type?
Cost price (4 decimal) data type?
Extented price ( 2 decimal) data type?
Birth Date data type?
User id data type?
Time entered data type?

Thanks again for your response.

regards,

Mesut

Mar 9 '06 #3
"mesut demir" <me*********@noveonbe.com> schrieb
Hi Armin,

Thank you for repsonse. I learnt more from your links you sent. But
I would like to create a file and I create some fields. I need to
assign data types to that fields. My problem is which data type do I
assign to the fields.
e.g. I create a file and the file has a field "NAME" 50 positions.
Okay what should be the DATA type for this in is it CHAR or VARCHAR
or NVARCHAR or NVAR or TEXT or NTEXT ?????....
No, it's neither char nor varchar nor nvarchar because the file is not a
database.

Actually there are two questions:

a) Which data type to use for variables to hold the values?

See the links given to choose the right type. (String for Name, Decimal for
Salary etc.)

b) How to store the values in the file?

This depends on a). You can store each type in different formats in a file.
For example, you can store a Decimal value in a binary format or you can
convert it to a String before.
If you store Strings in a file, you must choose the right encoding. In
memory, Strings are stored as Unicode character codes. If you write a String
to a file, you can use different encodings like Unicode, UTF-8, ANSI etc. Be
aware that some encodings do not have a fixed byte count per char, like
UTF-8. Have a look at the System.Text.Encoding class for more information.
Moreover, do you have a free choice of the file format or can you specify it
on your own? Why did you choose this format? Do you want to have a random
access file (fixed record length)
http://msdn.microsoft.com/library/en...FileAccess.asp

or a sequential file (different record length)?

http://msdn.microsoft.com/library/en...FileAccess.asp

There are also XML files, and we have serialization.

http://msdn.microsoft.com/library/en...ingobjects.asp

Currently, my impression is that a random access file (see 1st link above)
is appropriate.

But, the main question is: What is your intention?

For that reason I have created a file BELOW but what should be the
data type of these fields below
Can you help me with that ? From there I can learn...

TESTFILE:
--------------
Name data type?
Address data type?
City data type?
Salary Amount (2 decimal) data type?
Age data type?
Gender (value M/F) data type?
length (2 decimal) data type?
Quantity ( 0 decimal) data type?
Cost price (4 decimal) data type?
Extented price ( 2 decimal) data type?
Birth Date data type?
User id data type?
Time entered data type?

Armin

Mar 9 '06 #4
Hi Armin,

Sorry that I express my self wrong.... I'm coming from 3GL world so
with FILE I meant database file...

So I would like to create a database file or database table (to store
the name, adress etc the record information )...
I'm struggling about assigning correct datatypes to fields.

So this is not a programming question... I use the Microsoft SQL
database.

intention: I would like to create some DATABASE files and I would like
to access via VB.NET. I have installed on my pc Visual Basic Express
Edition, + Free MS SQL -> the free ware package to learn Visual basic
..Net.
I would liket to create some DATABASE TABLES/FILES and try to fill in
in my program in form. I need to define the DATABASE tables (fields)

I hope I explained well this time...

Sorry again I expressed myself wrong in my previous e-mail and I hope
this time I wrote correct, ...

Thanks again for your repsonse,

best regards,

Mesut

Mar 9 '06 #5
Armin's first link is your holy grail. It details exactly what each
datatype is.

In general...

We use nvarchar to store almost all Strings. The n indicates it is a
unicode field. You will also need to specify length (up to 4000
characters).

Other notable types are int, float, money, datetime, etc. Money will
actually give you 4 decimals but it's handy.

Again, check that link above for the nitty gritty details of each type.

e.g.
Name nvarchar(50)
Address nvarchar(50)
City nvarchar(20)
Salary Amount (2 decimal) money

Mar 9 '06 #6
"mesut demir" <me*********@noveonbe.com> schrieb
Hi Armin,

Sorry that I express my self wrong.... I'm coming from 3GL world so
with FILE I meant database file...

So I would like to create a database file or database table (to
store the name, adress etc the record information )...
I'm struggling about assigning correct datatypes to fields.

So this is not a programming question... I use the Microsoft SQL
database.

intention: I would like to create some DATABASE files and I would
like to access via VB.NET. I have installed on my pc Visual Basic
Express Edition, + Free MS SQL -> the free ware package to learn
Visual basic .Net.
I would liket to create some DATABASE TABLES/FILES and try to fill
in in my program in form. I need to define the DATABASE tables
(fields)

I hope I explained well this time...

Now I understand. :-) Well, I gave you to the link to the list of available
data types for SQL server. Accessing databases is a broad topic, so I can
only post the link to the documentation:

http://msdn.microsoft.com/library/en...withadonet.asp

Maybe you also want to download the "SQL Server Management Studio Express"
(3rd link):

http://msdn.microsoft.com/sql/express/

There is also a link to the "SQL Server 2005 Books Online (December 2005)".

The best newsgroup for ADO.Net related questions is
microsoft.public.dotnet.framework.adonet.

Armin

Mar 9 '06 #7
Hi Figital,

Thank you too... I have looked at the links and printed Armin send. At
the links is an overview which data types exist. I see there are some
data types for NUMERIC, Alpha-NUMERIC, DECIMALS etc.

e.g. Why do you use NVARCAR for NAME/ADDRESS/ etc. in your sample? Why
don't you use NCHAR or NTEXT or maybe CHAR? and Why do you use Data
type MONEY for Salary or AMOUNTS and not DECIMAL?

Last stupid question... Will there be big difference using VARIABLE
data types rather than FIXED datatypes. e.g. between NCHAR & NVARCHAR

Thanks again for your answers,

regards,

Mesut

Mar 9 '06 #8
I have never used SqlVariant. From what I understand you shouldn't use
this unless you have a good reason.

nvarchar is (usually) better than nchar because it only takes up as
much space as need PER record.

nvarchar (50) is a max length of 50, whereas nchar(50) is exactly 50.
Thus, the space required to store "Michael" would be approx 6 vs 50.

Char _can_ have benefits but for this type of data, you won't see them.

I have never used nText because I have never needed moer than 4000
characters in a single field. If you were storing things bigger than
that, you would need it. In general, I use the smallest datatype that
gets the job done.

Bigger datatypes don't just make for bigger databases...they can effect
performance all around.

While I've never actually done this myself, you might find it
informative to poke around the Northwind database to see how things are
setup.

Mar 9 '06 #9
Thank you very much again Figital. I now much have better understing
data types.

btw Armin thank you too for the usefull links you sent...

best regards,

Mesut

Mar 9 '06 #10
Mesut,

Be aware that a field type name on database server mark A can mean or be
stored something different as on server mark B.

Cor

"mesut demir" <me***@edpnet.be> schreef in bericht
news:11*********************@j52g2000cwj.googlegro ups.com...
Thank you very much again Figital. I now much have better understing
data types.

btw Armin thank you too for the usefull links you sent...

best regards,

Mesut

Mar 10 '06 #11
Hi Cor,

I learnt 1 more thing now. Thank you for tip, I'll keep in mind....

best regards,

Mesut

Mar 10 '06 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Erik Max Francis | last post by:
I've come across a limitation in unpickling certain types of complex data structures which involve instances that override __hash__, and was wondering if it was known (basic searches didn't seem to...
7
by: Neil Ginsberg | last post by:
I'm having some problems with an Access 2000 MDB file with a SQL Server 7 back end, using ODBC linked tables. I previously wrote about this, but am reposting it with some additional information and...
10
by: nambissan.nisha | last post by:
I am facing this problem.... I have to define a structure at runtime as the user specifies... The user will tell the number of fields,the actual fields...(maybe basic or array types or...
1
by: ShailShin | last post by:
Hi All, I have to convert Excel data to MSAcess .MDB file using VB.NET. VB.NET Code read the Excel file and write it to .MDB file. For the same I have below code, but I am stuck at the writing it...
5
by: rAinDeEr | last post by:
Hi, I have a web application with a table to store terms and conditions of a Company. This may some times run into many pages and some times it may be just a few sentences. It is a character...
7
by: greywire | last post by:
So I need to load lots of data into my database. So I discover LOAD DATA INFILE. Great! This little gem loads my CSV in blazing times (compared to parsing the file and doing INSERT for each...
6
by: sara | last post by:
I have what I think is a little strange...I have to get data from our payroll system into a specific format (fixed record length) as a .txt or .prn file only to upload to our 401k custodian. I...
8
by: mlwerth | last post by:
Dear Access Group: This is the most basic and most embarrassing of questions, but I cannot find where to change the data type of a text field that I have in Access 2003 to a number field. I've...
7
by: zdravko.monov | last post by:
Hi there! I need a C++ library that can organize and write scientific (and numerical overall) data in tables. I have been fighting with std::ofstream and plain ASCII files, but it is difficult to...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.