Hi I am using MS Oracle Driver or Oracle Driver (depending on application).
DataSource and DataMember of datagridview control. After I insert one record
primary key to the new record. On other side my dataset does not have
correct information since primary key has changed. I need to get new data
from dataset and bind it again with this datagrid. I would like to know what
"John" <John@Foo.com> wrote in message
news:OWv%2374RuFHA.3256@TK2MSFTNGP09.phx.gbl...
> Should that be Scope_Identity()?
>
> Jeffrey Tan[MSFT] wrote:
>> Hi Sinisa,
>>
>> Thanks for your post.
>>
>>
>>>Problem is that since I am generating primary key for this table in
>>
>> Oracle,
>>>my datagridview has different primary key then the one that is actual in
>>
>> database
>> I am not sure why the primary key in dataset is different from the
>> primary key in the database, normally, we suggest you use the same
>> primary key in dataset as in database.
>>
>> Do you use OLEDbdataAdapter to do the database operation? Do you use data
>> adapter configuration wizard to gerenate OLEDbdataAdapter? Normally, when
>> we are using data adapter configuration to generate the code, there is a
>> "Advanced Option" dialog, which we can check the "Refresh the DataSet"
>> option. With this option turned on, VS.net will add a Select statement
>> after Insert and Update command to retrieve identity column value,
>> default values, and other values calculated by the database.
>>
>> Below is the command text generated for SqlDataAdapter:
>> this.sqlInsertCommand1.CommandText ="INSERT INTO jobs(job_desc, min_lvl,
>> max_lvl) VALUES (@job_desc, @min_lvl, @max_lvl); SELECT job_id, job_desc,
>> min_lvl, max_lvl FROM jobs WHERE (job_id = @@IDENTITY)";
>>
>> If you do not use the wizard to generate the Insert command, I think you
>> have to maually add this additional insert statement. Addtionally,
>> because @@IDENTITY only returns the last identity value, if we insert
>> multi-records, we'd better re-select the entire table from DataBase into
>> the datatable.(That is remove "WHERE (job_id = @@IDENTITY)" from the
>> select command text abvoe)
>>
>> Also, because this issue is more ADO.net related than Winform databinding
>> issue, I suggest you post such issue in ADO.net newsgroup later on, then
>> you will get more useful reply and help. Thanks
>>
>> Best regards,
>> Jeffrey Tan
>> Microsoft Online Partner Support
>> Get Secure! -
www.microsoft.com/security >> This posting is provided "as is" with no warranties and confers no
>> rights.
>>