What to search for


M

Miro

Hi sorry for the quick question. I am on the right track but just cant seem
to find what to search for in my books / online for the answer I am looking
for.

I have created a dataset within my project.
In the dataset I created 2 tables - and set some fields on the tables.
In each table I set one of the fields to be a primary key / unique auto
incremenet.

So now I create a form, add a datagrid view to it and add to the dataset.
Works great. The unique keys are "negative" as expected.
If i was actaully pushing this to a sql server...on push i would expect it
to come back as a positive.

But I am not..
After this step I am writing the dataset to an XML file, but it still has
"negatives" there.
How to I get it to write to the xml file with "Positive Keys".
Basically make the XML file be my 'sql server'.

I can load and save my changes to the xml file - but the negatives are
there.
Or am i mislead, and using primary keys on an xml file will always be like
this - until you take it and write the contents into a real server
filesystem?

So I am not sure what to search for / google on "XML vb.net unique key
dataset" or something to find out how people use an xml file as a file
system.

Thanks.

Miro
 
Ad

Advertisements

G

Göran Andersson

Miro said:
Hi sorry for the quick question. I am on the right track but just cant
seem to find what to search for in my books / online for the answer I am
looking for.

I have created a dataset within my project.
In the dataset I created 2 tables - and set some fields on the tables.
In each table I set one of the fields to be a primary key / unique auto
incremenet.

So now I create a form, add a datagrid view to it and add to the dataset.
Works great. The unique keys are "negative" as expected.
If i was actaully pushing this to a sql server...on push i would expect
it to come back as a positive.

But I am not..
After this step I am writing the dataset to an XML file, but it still
has "negatives" there.
How to I get it to write to the xml file with "Positive Keys".
Basically make the XML file be my 'sql server'.

I can load and save my changes to the xml file - but the negatives are
there.
Or am i mislead, and using primary keys on an xml file will always be
like this - until you take it and write the contents into a real server
filesystem?

So I am not sure what to search for / google on "XML vb.net unique key
dataset" or something to find out how people use an xml file as a file
system.

Thanks.

Miro

It's not the primary key setting that makes the values change, it's that
the field is specified as identity in the database.

When you save the data as XML, there is no identity field that can
create new unique values.
 
M

Miro

Ahh I see, so I can also assume that it being negatives ( and since they are
hidden fields ) technically 'who cares'.
That or I run thru the dataset, find the next number in sequence and do it
myself.

Thank you very much.

Miro
 
C

Cor Ligthert[MVP]

Miro,

In my idea that is not the right way, because now you have to write the
DataSet with the diffgram option.

Why not simple use a GUID as identifier and leave that old Access way behind
you.

Cor

Miro said:
Ahh I see, so I can also assume that it being negatives ( and since they
are hidden fields ) technically 'who cares'.
That or I run thru the dataset, find the next number in sequence and do it
myself.

Thank you very much.

Miro
 
M

Miro

In my scenario I created - I am trying to create a dummy poker timer for him
and save his settings to an xml file.
That way sql express doesnt need to be installed or anything.
(Basically 1 step up from a csv file - so I can learn a bit on how to use
xml files - and he gets a dummy poker timer )

So this xml file is never shared by anyone / never used by multiple people
at the same time. It basically just stores the rounds & blinds.

With a scenario like this - yes I see how a GUID would be better than my
unique auto-incrementing key.
Because with this scenario - if i use my auto-incremeneting key idea - yes
everything works - but its still a negative# that is written to the xml
file. Your GUID would fix it - or I would have to manually run through and
search for negative keys and convert them to positive ones.

I am now just trying to think of an example ( cause I thought a poker timer
would be simple enough ), where my xml idea with keys would work.
But from what I have come to learn, is basically - if "I/Anyone" plans to
use an xml file as a 'settings file (like in my case)", then if I want to
have keys - I should ALWAYS use a GUID as the key, and the Unique
Auto-Increment Key setting - use that only if ever connecting to a database.

Is that a correct assumption?

Miro

Cor Ligthert said:
Miro,

In my idea that is not the right way, because now you have to write the
DataSet with the diffgram option.

Why not simple use a GUID as identifier and leave that old Access way
behind you.

Cor
 
G

Göran Andersson

Miro said:
In my scenario I created - I am trying to create a dummy poker timer for
him and save his settings to an xml file.
That way sql express doesnt need to be installed or anything.
(Basically 1 step up from a csv file - so I can learn a bit on how to
use xml files - and he gets a dummy poker timer )

So this xml file is never shared by anyone / never used by multiple
people at the same time. It basically just stores the rounds & blinds.

With a scenario like this - yes I see how a GUID would be better than my
unique auto-incrementing key.
Because with this scenario - if i use my auto-incremeneting key idea -
yes everything works - but its still a negative# that is written to the
xml file. Your GUID would fix it - or I would have to manually run
through and search for negative keys and convert them to positive ones.

Why would negative key values be a problem in the first place?
I am now just trying to think of an example ( cause I thought a poker
timer would be simple enough ), where my xml idea with keys would work.
But from what I have come to learn, is basically - if "I/Anyone" plans
to use an xml file as a 'settings file (like in my case)", then if I
want to have keys - I should ALWAYS use a GUID as the key, and the
Unique Auto-Increment Key setting - use that only if ever connecting to
a database.

Is that a correct assumption?

No.

A GUID is excellent if you have distributed data, i.e. you need to
create unique keys without having all the data available at the moment.
In your case your data is limited to your xml file, so you always have
all the data. Therefore you can always create a unique value without
problem, and the usefulness of a GUID is very small.
 
Ad

Advertisements

C

Cor Ligthert[MVP]

"Göran Andersson"
A GUID is excellent if you have distributed data, i.e. you need to create
unique keys without having all the data available at the moment. In your
case your data is limited to your xml file, so you always have all the
data. Therefore you can always create a unique value without problem, and
the usefulness of a GUID is very small.

Why is an incremental identifier better, it gives me always troubles which a
GUID does not.

I only use an incremental value for a key as I want the key have an
incremented number, but that is as well not the case in this situation.

Cor
 
G

Göran Andersson

Cor said:
"Göran Andersson"


Why is an incremental identifier better, it gives me always troubles
which a GUID does not.

It's smaller and faster. I use identity fields all the time, and don't
have any troubles with them.

In this case the advantage of the incremental identifier is that it's
already there, created automatically. To use a GUID you have to
specifically create them.
I only use an incremental value for a key as I want the key have an
incremented number, but that is as well not the case in this situation.

I use an identity field as the simplest way of creating a unique key,
never to create an incremental value. If you need to rely on a value
being truly incremental, you should create the values yourself so that
you are sure that they really are.
 
Ad

Advertisements

M

Miro

In my case I really dont care what they are, i just need a unique key for
some files.

I'll play with both, I was just under the impression that I was writing
something wrong - and getting negative keys to my xml file.
The dataset I knew was ok - the actual xml file I did not know.

Miro
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top