Re: Ado.net DataSet Refresh



If you use one of the binding techniques, this refresh is done
automatically.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------

"Manjree Garg" <garg@xxxxxxxxxxxxxxxx> wrote in message
news:5ACF470B-C349-45B8-BBE3-13CBBD37878F@xxxxxxxxxxxxxxxx
Hi Bill

I am just fetching the data from the DataTable's row and displaying in the
list. The code is something like that:

DataRowCollection^ rows = samplesTable->Rows;
for (i = 0; i < rows->Count; i++)
{
row = rows->default[i];
supplierid = row->default[L"supplierID"]->ToString();
id = row->default[L"sampleID"]->ToString();
type = row->default[L"type"]->ToString();

int idx = lst.InsertItem(i, (CString)id);
lst.SetItemText(idx, 1, (CString)supplierid);
lst.SetItemText(idx, 2, (CString)type);;
}

After adding new records when I list the records It does not list the
newly
inserted records.

Thanks.

Manjree

"William (Bill) Vaughn" wrote:

How are you binding to the DataTable/DataView?

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no
rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------

"Manjree Garg" <garg@xxxxxxxxxxxxxxxx> wrote in message
news:E4EF2CA2-FF0C-4F18-96FC-D15B687F0D92@xxxxxxxxxxxxxxxx
Thanks for your reply. I

I am using dataset to list all the records in CListView. And after
insertion
when I list all the records in the table It does not list the newly
inserted
records. Though if I close the application and run it again all the
records
are listed via DataSet. Means that for the first time it Fills all the
records but after insertion it does not refresh it.

Manjree

"William (Bill) Vaughn" wrote:

By default, Fill simply reexecutes the query and appends the new rows
to
an
existing DataTable... did you look for the new rows at the end?

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no
rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest
book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------

"Manjree Garg" <garg@xxxxxxxxxxxxxxxx> wrote in message
news:B39F1381-1FB4-43FB-B49F-F2432D393236@xxxxxxxxxxxxxxxx
Hi

Is there any way to refresh a DataSet after inserting few records in
a
table
(containing foreignKey column) using adapters' InsertCommand and
ExecuteNonQuery(). I tried adapter's Fill(dataSet) but it does not
add
the
new records inserted to the dataset's table. I am doing something
like:

adapter->InsertCommand = gcnew SqlCommand(L"INSERT INTO Sample " +
"(sampleID, type, dateReceived, dateExpiry,
supplierID)"+
" VALUES (@sampID, @type, @dtRcvd, @dtExp, @suppID)", conn);

int r = adapter->InsertCommand->ExecuteNonQuery();
adapter->Fill(dataset);

Ofcourse all the parameter's are defined and the record is inserted
to
the
dataSource table.

Because of the foreignKey column I can not just add a newRow to
DataSet
and
then use adapter's Update() method as it throws an exception.

I am using VC++ (VisualStudio 2005 and SQL Server 2005) for the
interface.

Thanks for any information.

Manjree











.



Relevant Pages


Loading