February 14, 2006 at 3:17 pm
do I need to fill a dataAdapter if I only want to insert new records. If so what form does the SelectCommand take
February 14, 2006 at 8:05 pm
Create an xml string of the fields you want to insert. Call a stored procedure that passes a text variable of your xml to the server.
HTH
Mathew J Kulangara
sqladventures.blogspot.com
February 16, 2006 at 6:10 am
David,
It is the DataSet that holds the data. There is no requirement to have a select command associated with a DataAdapter. If you only want it to insert data just define the insert command.
May I ask what if anything you are binding the dataset to and whether the application is a web, Windows or Console app.
regards
Shaun
Quis custodiet ipsos custodes.
February 16, 2006 at 12:53 pm
Shaun Hi,
I'm writting a windows application to add new records to some tables.
I thought that you had to run dataAdapter.Fill
(which I assumed implies a Select statment)
to at least get the table structure before you could make any changes or additions to a dataTable
February 17, 2006 at 2:06 am
David,
I assume that you are using untyped DataSets. This being the case I would think that a Select Statement would be needed to generate the appropriate structure.
There is another type of DataSet, the typed DataSet, this can be configured in the Designer simply by adding a Dataset to your project and dragging the table structure from your chosen database onto it. This typed dataset already possesses the structure of the table and thus does not need a select statement to configure it prior to adding records.
There is a useful link below:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vboriDatasets.asp
If it would help I could send you a simple worked example because one showing is worth a thousand tellings
regards
Shaun
Quis custodiet ipsos custodes.
February 17, 2006 at 2:06 am
David,
I assume that you are using untyped DataSets. This being the case I would think that a Select Statement would be needed to generate the appropriate structure.
There is another type of DataSet, the typed DataSet, this can be configured in the Designer simply by adding a Dataset to your project and dragging the table structure from your chosen database onto it. This typed dataset already possesses the structure of the table and thus does not need a select statement to configure it prior to adding records.
There is a useful link below:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vboriDatasets.asp
If it would help I could send you a simple worked example because one showing is worth a thousand tellings
regards
Shaun
Quis custodiet ipsos custodes.
February 17, 2006 at 2:06 am
David,
I assume that you are using untyped DataSets. This being the case I would think that a Select Statement would be needed to generate the appropriate structure.
There is another type of DataSet, the typed DataSet, this can be configured in the Designer simply by adding a Dataset to your project and dragging the table structure from your chosen database onto it. This typed dataset already possesses the structure of the table and thus does not need a select statement to configure it prior to adding records.
There is a useful link below:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vboriDatasets.asp
If it would help I could send you a simple worked example because one showing is worth a thousand tellings
regards
Shaun
Quis custodiet ipsos custodes.
February 18, 2006 at 4:13 am
Hi Shaun
I've got it all working thanks.
The problem is there's so many ways to do the same thing and I don't know which is the most efficient.
For instance to delete all the records in a table
I first loaded them all into a dataTable and then
For Each row in ds.Tables("tblUser").Rows
row.Delete()
Next
Then I added new rows to the dataTable before running dataTable.Update
This all works, but I think it's taking alot longer than it should if I was doing it the 'right' way.
February 20, 2006 at 2:09 am
Hi David,
I'm glad that everything is now working:
You are not wrong about the number of ways to manipulate data within the .Net framework.
Please do make the effort to differentiate between the methods. This knowledge will have a significant effect on the resource utilisation and the performance of your applications and systems. Perhaps not so much in single user apps but where there are hundreds perhaps thousands of users, it really makes a difference
regards
Shaun
Quis custodiet ipsos custodes.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply