none
Unable to add SqlDataAdapter to project

    Question

  • I am running the following:

    Microsoft Visual Studio 2005
    Version 8.0.50727.42  (RTM.050727-4200)
    Microsoft .NET Framework
    Version 2.0.50727

    Installed Edition: Enterprise

    I have a simple web page that I want to put a SqlDataAdapter on.

    It is not on my Toolbox, nor will it allow me to add it to the source. I had to check the option in Choose Items, the toolbox blinks, but it doesn't show the tool.

    How do I get that tool into my program?

    Bill

     

    Wednesday, January 10, 2007 6:58 PM

Answers

  •  

    Public Sub LoadData()
            Dim ds As New DataSet

    Using Adapter As New SqlClient.SqlDataAdapter
            Adapter.SelectCommand.CommandText = "SELECT * FROM Titles"

          Try
            Adapter.Fill(ds,"Titles_Record")

    Catch e as exception

    'Error processing here
     End  Try


            DataList1.DataSource=ds
            DataList1.DataBind
            End Using


    end sub

    Wednesday, January 10, 2007 7:48 PM

All replies

  • Have you made a reference to the System.Data.SQLClient namespace?
    Wednesday, January 10, 2007 7:07 PM
    Moderator
  • I tried to add a reference to it, but it won't stick. I opened the property pages, clicked on Add Reference, Selected System.Data.Sqlclient and clicked on OK. The references for the project blinked, but it is not there.
    Wednesday, January 10, 2007 7:24 PM
  •  

    You need to do an Imports System.Data.Sqlclient above your class definition.

    Then:

    Using Adapter As New SqlClient.SqlDataAdapter

    End Using

    Or SImply

    DIM Adapter As New SqlClient.SqlDataAdapter

     

     

    Wednesday, January 10, 2007 7:35 PM
  • I already have the Imports System.Data.SqlClient above my calss

    I want to add the SQLDataAdapter to the project and reference it from code, like this:

    Public Sub LoadData()
            Dim ds As New DataSet
            SqlDataAdapter1.SelectCommand.CommandText = "SELECT * FROM Titles"
            SqlDataAdapter1.Fill(ds,"Titles_Record")
            DataList1.DataSource=ds
            DataList1.DataBind()
    end sub

    Wednesday, January 10, 2007 7:43 PM
  •  

    Public Sub LoadData()
            Dim ds As New DataSet

    Using Adapter As New SqlClient.SqlDataAdapter
            Adapter.SelectCommand.CommandText = "SELECT * FROM Titles"

          Try
            Adapter.Fill(ds,"Titles_Record")

    Catch e as exception

    'Error processing here
     End  Try


            DataList1.DataSource=ds
            DataList1.DataBind
            End Using


    end sub

    Wednesday, January 10, 2007 7:48 PM