Home All Groups Group Topic Archive Search About

Unable to Created Data View

Author
4 Dec 2006 9:37 PM
OutdoorGuy
Greetings,

I am attempting to use the following code in order to create a DataView
(in VB.NET 2003).  However, on the "Dim dv as New DataView" line I am
receiving a "Type expected" error.  Any ideas?

Thanks in advance!

********************************************************
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim sqlConn As New SqlClient.SqlConnection
....
sqlComm.Connection = sqlConn
sqlComm.CommandText = "Select * from Books"

Dim da As New SqlClient.SqlDataAdapter
da.SelectCommand = sqlComm

Dim ds As New DataSet

Try
   da.Fill(ds, "Books")

   Dim dv As New DataView(ds.Tables("Books"), " ", "Author",
DataViewRowState.CurrentRows)
--> "'Type Expected' error occurs here"

   Dim frow As Integer
   frow = dv.Find("Simpson")

   ListBox1.Items.Add(dv(frow)("Author").ToString() & " " &
dv(frow)("Title").ToString())

Catch er As Exception
   MsgBox(er.Message)

End Try

*** Sent via Developersdex http://www.developersdex.com ***

Author
5 Dec 2006 5:31 AM
Cor Ligthert [MVP]
Hi,

Are you sure that there is not "nothing" returned, there are quite a few
parameters which can prevent that.

Cor

Show quoteHide quote
"OutdoorGuy" <Outdoor***@fishing.com> schreef in bericht
news:OQSOnx%23FHHA.4464@TK2MSFTNGP03.phx.gbl...
> Greetings,
>
> I am attempting to use the following code in order to create a DataView
> (in VB.NET 2003).  However, on the "Dim dv as New DataView" line I am
> receiving a "Type expected" error.  Any ideas?
>
> Thanks in advance!
>
> ********************************************************
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button1.Click
> Dim sqlConn As New SqlClient.SqlConnection
> ...
> sqlComm.Connection = sqlConn
> sqlComm.CommandText = "Select * from Books"
>
> Dim da As New SqlClient.SqlDataAdapter
> da.SelectCommand = sqlComm
>
> Dim ds As New DataSet
>
> Try
>   da.Fill(ds, "Books")
>
>   Dim dv As New DataView(ds.Tables("Books"), " ", "Author",
> DataViewRowState.CurrentRows)
> --> "'Type Expected' error occurs here"
>
>   Dim frow As Integer
>   frow = dv.Find("Simpson")
>
>   ListBox1.Items.Add(dv(frow)("Author").ToString() & " " &
> dv(frow)("Title").ToString())
>
> Catch er As Exception
>   MsgBox(er.Message)
>
> End Try
>
> *** Sent via Developersdex http://www.developersdex.com ***