创建文件时,为字段定义数据类型 [英] Defining data types for fields, when you a create a file

查看:115
本文介绍了创建文件时,为字段定义数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


当我创建字段(在文件中)时,我需要分配一个数据类型,如char,

varchar,money等。br />

我在

文件中创建字段时对数据类型有一些疑问。


有什么区别在数据类型''CHAR''和''TEXT''之间?

你什么时候在你的数据类型字中使用''VAR''?例如VARCHAR?

有什么区别''NVARCHAR''& ''VARCHAR''& ''CHAR''?

''VARCHAR''中的'N'是什么?


让我们说我想创建一个文件,见下面的字段。

你为它分配了什么数据类型?有人可以帮我分配数据

类型吗?


File1

======

名称数据类型?

地址数据类型?

城市数据类型?

工资金额(2位小数)数据类型?

年龄数据类型?

性别(价值M / F)数据类型?

长度(2位小数)数据类型?

数量(0小数)数据类型?

成本价格(4位小数)数据类型?

扩展价格(2位小数)数据类型?

出生日期数据类型?

用户ID数据类型?

输入时间数据类型?

谢谢你澄清这些数据类型。
< br $>
问候,


Mesut

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

推荐答案

" mesut德米尔" <我********* @ noveonbe.com> schrieb im Newsbeitrag

news:11 ********************* @ i39g2000cwa.googlegro ups.com ...
"mesut demir" <me*********@noveonbe.com> schrieb im Newsbeitrag
news:11*********************@i39g2000cwa.googlegro ups.com...
大家好,

当我创建字段(在文件中)时,我需要分配一个数据类型,如char,
varchar,money等。

我有在
文件中创建字段时有关数据类型的一些问题。

数据类型CHAR和TEXT之间有什么区别?
你在数据类型的单词中使用''VAR''吗?例如VARCHAR?
有什么区别''NVARCHAR'& ''VARCHAR''& ''CHAR''?
''VARCHAR''中的'N'是什么?


这些是数据库中使用的数据类型的名称。在VB.Net中,我们有其他的

数据类型,如String,Integer等。如果你想在文件中存储某些东西,为什么要引用数据库数据

类型?这可能是对的 - 只需要

询问。


要获得数据类型的说明,请查看
$ b $的文档b数据库。对于SQL Server:
http: //msdn.microsoft.com/library/en...da-db_7msw.asp

映射数据类型:
http://msdn.microsoft.com/library/en...kdatatypes .asp


假设我想创建一个文件,请参阅下面的字段。
您为它分配了什么数据类型?有人可以帮我分配数据类型吗?

文件1
======
名称数据类型?
地址数据类型?城市数据类型?
工资金额(2位小数)数据类型?
年龄数据类型?
性别(值M / F)数据类型?
长度(2位小数)数据类型?
数量(0十进制)数据类型?
成本价格(4位小数)数据类型?
延长价格(2位小数)数据类型?
出生日期数据类型?
用户ID数据类型?
时间输入数据类型?

谢谢你澄清这些数据类型。
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


(低于头l ine系统名称空间,列出了一些基本数据类型)

Armin


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


嗨Armin,


谢谢你的回复。我从您发送的链接中了解到更多信息。但我想要b $ b想要创建一个文件并创建一些字段。我需要将

数据类型分配给该字段。我的问题是我将哪种数据类型分配给

字段。

例如我创建了一个文件,该文件有一个字段NAME。 50个职位。

好​​的,DATA的类型应该是CHAR或VARCHAR还是

NVARCHAR或NVAR或TEXT或NTEXT ????? ... 。


因为这个原因我创建了一个文件BELOW但是数据应该是什么

下面这些字段的类型

可以你帮帮我了吗?从那里我可以学习......


TESTFILE:

--------------

名称数据类型?

地址数据类型?

城市数据类型?

工资金额(2位小数)数据类型?

年龄数据类型?

性别(价值M / F)数据类型?

长度(2位小数)数据类型?

数量(0小数)数据类型?

成本价格(4位小数)数据类型?

扩展价格(2位小数)数据类型?

出生日期数据类型?

用户ID数据类型?

时间输入数据类型?


再次感谢您的回复。


问候,


Mesut

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


" mesut demir" <我********* @ noveonbe.com> schrieb
"mesut demir" <me*********@noveonbe.com> schrieb
嗨Armin,

谢谢你的回复。我从您发送的链接中了解到更多信息。但是
我想创建一个文件,然后创建一些字段。我需要为这些字段分配数据类型。我的问题是我将哪些数据类型分配给字段。
例如我创建了一个文件,该文件有一个字段NAME。 50个职位。
这个数据类型应该是CHAR或VARCHAR
或NVARCHAR或NVAR或TEXT或NTEXT ????? ....


不,它既不是char也不是varchar也不是nvarchar,因为该文件不是

数据库。


其实有两个问题:


a)用于保存值的变量使用哪种数据类型?


请参阅给出的链接以选择正确的类型。 (姓名字符串,小数字表示

薪资等)


b)如何将值存储在文件中?


这取决于a)。您可以将不同格式的每种类型存储在一个文件中。

例如,您可以以二进制格式存储十进制值,或者您可以将
转换为字符串之前。

如果将字符串存储在文件中,则必须选择正确的编码。在

内存中,字符串存储为Unicode字符代码。如果你把一个字符串

写入一个文件,你可以使用不同的编码,如Unicode,UTF-8,ANSI等.B>

意识到某些编码没有修复每个字符的字节数,例如

UTF-8。请查看System.Text.Encoding类以获取更多信息。

此外,您是否可以自由选择文件格式,还是可以指定它?

拥有?你为什么选择这种格式?你想要一个随机的

访问文件(固定记录长度)
http://msdn.microsoft.com/library/en...FileAccess.asp


或顺序文件(不同的记录长度)?
http://msdn.microsoft.com/library/en...FileAccess.asp


还有XML文件,我们有序列化。

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


目前,我的印象是随机访问文件(参见上面的第一个链接)

是合适的。


但是,主要的问题是:你的意图是什么?


为此目的我已经创建了一个文件BELOW但是下面这些字段应该是什么数据类型
你能帮助我吗?从那里我可以学习......

TESTFILE:
--------------
名称数据类型?
地址数据类型?
城市数据类型?
工资金额(2位小数)数据类型?
年龄数据类型?
性别(价值M / F)数据类型?
长度(2位小数)数据类型?
数量(0小数)数据类型?
成本价格(4位小数)数据类型?
价格(2位小数)数据类型?
出生日期数据类型?
用户ID数据类型?
时间输入数据类型?
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


Armin

这篇关于创建文件时,为字段定义数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆