473,732 Members | 2,190 Online
Bytes | Software Development & Data Engineering Community
+ 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 3437
"mesut demir" <me*********@no veonbe.com> schrieb im Newsbeitrag
news:11******** *************@i 39g2000cwa.goog legroups.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*********@no veonbe.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.Enc oding 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*********@no veonbe.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.publi c.dotnet.framew ork.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...the y 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

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

Similar topics

1
2276
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 come up with anything similar) and if there is a workaround for it short of restructuring the data structures in question. The fundamental issue rests with defining classes which override __cmp__ and __hash__ in order to be used as keys in...
7
2294
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 in summary form, in hopes that someone might have an idea about what's going on. I am using a bound form which is losing data a significant portion of the time. Basically, the form contains 6 fields and three subforms, as follows: Field A...
10
2129
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 multiple arrays,etc) I do not understand how to define the structure at run time.i.e.what fields it will contain.
1
11369
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 to .MDB file. which I have already created with Table as Terms which contains 10 Fields and my Excel contains 10 Fields, Here I want to Extract 3 columns data from Excel to Table. Also it shows error of "syntax error in INSERT INTO Command. ...
5
3404
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 text field. I want to know which Data type I need to use so that it doesnt waste memory. thanks in advance, rAinDeEr
7
10159
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 row). Its still slow on large files, but just barely acceptable. Only one problem. It truncates fields to 256 characters, even on a text field.
6
8226
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 can get the data into Access (from Payroll) and write a query with all the fields (inserting fields with spaces, as needed), but I can't figure out how to get it to export to a .txt file - without the field name header row. I don't really ...
8
3271
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 searched high and low through help databases and on the internet. The directions say to : Open the table in Design view Click the Data Type column of the field you want to change, click the
7
2946
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 position columns by an offset, impossible to draw table borders etc. I am currently thinking of a class that is able to write to an html file, e.g. As far as I know, html offers much better text (and table) layout. And the format is portable!...
0
8946
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8774
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9447
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9307
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9181
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8186
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6031
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3261
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.