Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
SQLError
Yak Posting Veteran
63 Posts |
Posted - 2005-01-16 : 22:18:01
|
| Hi, in my program, I load a dialog box and call an sql statement SELECT * from MyTable WHERE ID = "xyz"Then I show those rows in a list box.From this dialog box, I can add another item. This item will be inserted into the table and I requery the table to retrieve the allthe required rows again(SELECT * from MyTable WHERE ID = "xyz")Then, I clear the list box and insert these items into it.I know there must be a better method. Can anyone give me some ideas. |
|
|
SQLError
Yak Posting Veteran
63 Posts |
Posted - 2005-01-16 : 22:20:23
|
| Just to add, if I were to save the result ofSELECT * from MyTable WHERE ID = xyz to a view andthen update and query this view until the dialog box is closed,is this better? |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-01-17 : 03:54:12
|
are you using .net?Go with the flow & have fun! Else fight the flow |
 |
|
|
MaverickUK
Yak Posting Veteran
89 Posts |
Posted - 2005-01-17 : 04:32:58
|
| If you are using .NET, you can hold the SQL data in a DataSet/DataTable after the first request.You can then do your update AND at the same time add a new row to the DataSet/DataTable you are still holding in memory.This means you'll only have to do one select statement and one insert. |
 |
|
|
SQLError
Yak Posting Veteran
63 Posts |
Posted - 2005-01-17 : 18:51:20
|
| hi, yes, I am using .net and I did think of going with datasets.The thing is, I was wondering what someone would do if he isnt using .net.What would you do MaverickUK? Was I correct in my thinking about creating a temp view to get the initial values, working on the view table and then deleting the view when I close the dialog box? |
 |
|
|
SQLError
Yak Posting Veteran
63 Posts |
Posted - 2005-01-17 : 20:40:54
|
| I will experiment, but off hand, regarding datasets, lets say I create one and it is stored in memory. What if one of the fields has a default value (I.e. NewID()). Is this taken care of if I do an insert and a modify on the dataset for the same item. |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-01-18 : 02:27:54
|
default values are handled in the dataset if you tell them to. otherwise they get handled in the db.i had some problems with GUID's being the default value. they didn't handle well. i had to insert one by hand for each row.well recordsets in ado 3.0 can also be updated all at once...Go with the flow & have fun! Else fight the flow |
 |
|
|
|
|
|
|
|