Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb_dotnet thread: Re: Strange ADO. NET Error


Message #1 by Richard Ainsley <rainsley@p...> on Sat, 12 Jan 2002 23:25:42 -0800
This is a multi-part message in MIME format.

------=_NextPart_000_0080_01C19BC0.743522B0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Terrance,

Unlike VB6, VB.net defaults with its equivelant  of "set explicit on".  
My guess is that you have not properly defined  objDA. Check carefully 
that you have a qualified definition ( using the imports statement in my 
code below)


....

Dim strSQL =3D "Select .... FROM ...."
Dim objDA as sqlclient.sqlDataAdapter
Dim objDataSet as DataSet
Dim objDataView as DataView
Dim objDataRowView as DataRowView
Dim i as Integer =3D 0

objDA =3D new sqlDataAdapter(strSQL, strConn)
objDataSet =3D New DataSet
objDA.Fill(objDataSet, "ArbitraryTableName")

objDataView =3D New DataView(objDataset.Tables("ArbitraryTableName"))

objDataView.rowfilter =3D "someField =3D SomeValue"

objDataview.sort =3D "somefield, someotherfield"

For i =3D 0 to objDataview.recordcount - 1

   objDataRowView =3D objDataview.Item(i)

   debug.print objDataRowView.Item("AnyFieldName").ToString

Next i

' code in this format does work.  Error messages coming from faulty SQL 
script are not always helpful.

' be careful to test your sql statement out while debugging the runtime 
if you jam on objDA.Fill(...)

'So far all my jams on that statement were SQL problems -- but the 
errors reported were usually not helpful.






  ----- Original Message -----
  From: Terrence Joubert
  To: pro_VB_dotnet
  Sent: Wednesday, December 19, 2001 7:11 AM
  Subject: [pro_vb_dotnet] Strange ADO. NET Error


  Hi Everyone,

  

  I am using Visual Studio .NET RC3.

  I am testing the piece of code on page 581 of the book Professional VB 
.NET. When I try to buid the application that contains this code chunk, 
the compiler gives me the following errors:

  

        Line of code
       Error
      
        objDA =3D New SqlClient.SqlDataAdapter(strSQL, strConn)
       Value of type 'System.Data.SqlClient.SqlDataAdapter' cannot be 
converted to '1-dimensional array of 
System.Data.SqlClient.SqlDataAdapter'.

        
      
        objDA.Fill(objDS)

        
       'Fill' is not a member of 'System.Array'.
      
        With objDS.Tables(0)

        
       'Tables' is not a member of 'System.Array'.
      

  

  Would anyone, perhaps the authors, have a clue of what these errors 
mean and how I can go around it?

  

  Thanks

  Terrence

  

$subst('Email.Unsub').



  Return to Index