Another Dtr Question

G

Guest

I have a table with no Lines on it. I enter the dtr as below with a counter set to 0 on the first time in. The dtr.Read is 'False'. This returns the message "No Lines on Order!
I then enter a new line on that screen and call the dtr again. The dtr.Read is True but the flow of control does not enter
the While (dtr.Read()) = True. I cannot understand why not. Any ideas welcome. Thanks, Marc

Tr
Dim dtr As SqlCeDataReader = cmdSQL.ExecuteReader(CommandBehavior.Default
Dim counter As String =
MessageBox.Show(dtr.Read
While (dtr.Read()) = Tru
MessageBox.Show(counter
item = New ListViewItem(dtr.GetSqlInt32(0).ToString
item.SubItems.Add(dtr.GetString(1)
item.SubItems.Add(dtr.GetSqlInt32(2).ToString
lstOrderDtl.Items.Add(item
counter = counter +
End Whil

If counter = 0 The
MessageBox.Show(counter
MessageBox.Show("No Lines on Order!"
End I
dtr.Close(
Catch ex As SqlCeExceptio
DisplaySQLCEErrors(ex
Finall
cmdSQL.Dispose(
End Try
 
A

Alex Feinman [MVP]

Every call to .Read advances the reader. The call to
MessageBox.Show(dtr.Read()) causes the only item in the datareader to be
"eaten", so that the next call to .Read correctly returns false.

--
Alex Feinman
---
Visit http://www.opennetcf.org
marcmc said:
I have a table with no Lines on it. I enter the dtr as below with a
counter set to 0 on the first time in. The dtr.Read is 'False'. This returns
the message "No Lines on Order!"
I then enter a new line on that screen and call the dtr again. The
dtr.Read is True but the flow of control does not enter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top