Click here to Skip to main content
15,902,189 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questionvb.net voice chat Pin
harddream24-May-07 4:44
harddream24-May-07 4:44 
AnswerRe: vb.net voice chat Pin
Colin Angus Mackay24-May-07 4:57
Colin Angus Mackay24-May-07 4:57 
GeneralRe: vb.net voice chat Pin
Johan Hakkesteegt25-May-07 0:45
Johan Hakkesteegt25-May-07 0:45 
QuestionRetrieving Windows User name/ID Pin
robw188824-May-07 4:35
robw188824-May-07 4:35 
AnswerRe: Retrieving Windows User name/ID Pin
Dave Kreskowiak24-May-07 5:37
mveDave Kreskowiak24-May-07 5:37 
GeneralRe: Retrieving Windows User name/ID Pin
robw188824-May-07 5:41
robw188824-May-07 5:41 
AnswerRe: Retrieving Windows User name/ID Pin
Dave Herren24-May-07 6:13
Dave Herren24-May-07 6:13 
QuestionStill having a problem using DataSets Pin
Quecumber25624-May-07 4:24
Quecumber25624-May-07 4:24 
Hi Everyone:
I still have a nagging problem when it comes to using DataSets.

When I add new records to a dataset that contains nothing but the table’s schema, the dataset starts the auto increment field primary key field off at zero instead of one. I’m using an article titled “How to update a database from a DataSet object using Visual Basic NET”, to help me understand how to use datasets for data manipulation.

The article states, “To access primary key information, call FillSchema, and then set the MissingSchemaAction property of your DataAdapter to AddWithKey, or manually set the primary key in your code.”
I have done this and here is my problem.

When I add new records to an empty dataset, before I update the database the records look like this

0 Record 1
1 Record 2
2 Record 3
3 Record 4

As long as I don’t use the navigation buttons to move back to other records. I can save the DataSet to the database and it will look like this:

1 Record 1
2 Record 2
3 Record 3
4 Record 4

Now I’m going to show you where the monkey wrench comes into play. I load the dataset from the database. The dataset that is returned looks like this:

1 Record 1
2 Record 2
3 Record 3
4 Record 4

If I add a new record to the dataset like:

1 Record 1
2 Record 2
3 Record 3
4 Record 4
0 Record 5

I go back to another record to perform an edit and the dataset looks like this:
1 Record 1
2 Record 2
3 RECORD 3 <edit performed="" on="" this="" record="">
4 <blank>
0 Record 5

If I commit the changes made on the DataSet to the database, both addition and edited record. The database table changes to this:

1 Record 1
2 Record 2
3 RECORD 3
4 <blank>
5 Record 5

I don't understand why this is occuring. The dataset is based on the table schema, so logically it should know the first column is the primary key column and the primary key column is auto incremented. It starts at one and increments by one every time we add a new record.

To me it looks like the DataSet doesn't know that when I add a new record to the dataset to take the ID number of the last record and increment it by one to get the next primary key number. The DataSet also doesn't seem to append the new record at the end of the dataset. In other words advance to the end of the dataset, add the new record with the new ID number and so forth.

Why is this happening and what can I do to fix it?

Thanks,


Quecumber256
AnswerRe: Still having a problem using DataSets Pin
Guffa24-May-07 6:40
Guffa24-May-07 6:40 
GeneralRe: Still having a problem using DataSets Pin
Quecumber25624-May-07 6:56
Quecumber25624-May-07 6:56 
GeneralRe: Still having a problem using DataSets Pin
Dave Kreskowiak24-May-07 7:02
mveDave Kreskowiak24-May-07 7:02 
GeneralRe: Still having a problem using DataSets Pin
Quecumber25624-May-07 7:35
Quecumber25624-May-07 7:35 
GeneralRe: Still having a problem using DataSets Pin
Dave Kreskowiak24-May-07 7:44
mveDave Kreskowiak24-May-07 7:44 
GeneralRe: Still having a problem using DataSets Pin
Quecumber25624-May-07 8:39
Quecumber25624-May-07 8:39 
Questionbinding crystal report fiels at run time Pin
Ajeet mittal24-May-07 4:21
Ajeet mittal24-May-07 4:21 
AnswerRe: binding crystal report fiels at run time Pin
Steven J Jowett24-May-07 4:28
Steven J Jowett24-May-07 4:28 
AnswerRe: binding crystal report fiels at run time Pin
Rupesh Kumar Swami24-May-07 4:38
Rupesh Kumar Swami24-May-07 4:38 
QuestionHow to allocate memory in VB 6.0 Pin
AR Reddy24-May-07 3:02
AR Reddy24-May-07 3:02 
AnswerRe: How to allocate memory in VB 6.0 Pin
Dave Herren24-May-07 4:21
Dave Herren24-May-07 4:21 
GeneralRe: How to allocate memory in VB 6.0 Pin
Dave Kreskowiak24-May-07 5:33
mveDave Kreskowiak24-May-07 5:33 
AnswerRe: How to allocate memory in VB 6.0 Pin
Dave Kreskowiak24-May-07 5:32
mveDave Kreskowiak24-May-07 5:32 
GeneralRe: How to allocate memory in VB 6.0 Pin
AR Reddy24-May-07 18:58
AR Reddy24-May-07 18:58 
GeneralRe: How to allocate memory in VB 6.0 Pin
Dave Kreskowiak25-May-07 11:52
mveDave Kreskowiak25-May-07 11:52 
Questionset image for Label Dynamically Pin
Rupesh Kumar Swami24-May-07 2:36
Rupesh Kumar Swami24-May-07 2:36 
AnswerRe: set image for Label Dynamically Pin
alhokail24-May-07 12:45
alhokail24-May-07 12:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.