I have the following code;
Dim conn As New SqlConnection()
Dim cmd As New SqlCommand
Dim myreader As SqlDataReader
Dim adapter As New SqlDataAdapter
lsql = "Select effect_dat, fxrate, currency from [sec_mast].[dbo].[sec_fxrt] where currency = 'EUR' order by effect_dat desc"
conn = New SqlConnection(strconnect)
Try
conn.Open()
Catch ex As Exception
MessageBox.Show("Connection To Server failed")
End Try
cmd.Connection = conn
Dim dm As New DataTable
Try
cmd = New SqlCommand(lsql, conn)
adapter.SelectCommand = cmd
adapter.Fill(dm)
adapter.Dispose()
cmd.Dispose()
Catch ex As Exception
MessageBox.Show("cannot open connection")
End Try
Dim myrow As DataRow
'
' following loads the data into the listview
'
For Each myrow In dm.Rows
ListView1.Items.Add(myrow.Item(0))
ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(myrow.Item(1))
ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(myrow.Item(2))
ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(myrow.Item(3))
Next
My problem is that the SQL statements returns 3898 rows of data but only the first row gets displayed in the listview
I have similar code that works using oledbdataadapter
can anyone point out what I am missing here..
thanks in advance for any comments/suggestions
Dim conn As New SqlConnection()
Dim cmd As New SqlCommand
Dim myreader As SqlDataReader
Dim adapter As New SqlDataAdapter
lsql = "Select effect_dat, fxrate, currency from [sec_mast].[dbo].[sec_fxrt] where currency = 'EUR' order by effect_dat desc"
conn = New SqlConnection(strconnect)
Try
conn.Open()
Catch ex As Exception
MessageBox.Show("Connection To Server failed")
End Try
cmd.Connection = conn
Dim dm As New DataTable
Try
cmd = New SqlCommand(lsql, conn)
adapter.SelectCommand = cmd
adapter.Fill(dm)
adapter.Dispose()
cmd.Dispose()
Catch ex As Exception
MessageBox.Show("cannot open connection")
End Try
Dim myrow As DataRow
'
' following loads the data into the listview
'
For Each myrow In dm.Rows
ListView1.Items.Add(myrow.Item(0))
ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(myrow.Item(1))
ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(myrow.Item(2))
ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(myrow.Item(3))
Next
My problem is that the SQL statements returns 3898 rows of data but only the first row gets displayed in the listview
I have similar code that works using oledbdataadapter
can anyone point out what I am missing here..
thanks in advance for any comments/suggestions