Results 1 to 6 of 6

Thread: SqlDataAdapter question!

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    5

    Question SqlDataAdapter question!

    I need to use the SqlDataAdapter class in my code. I am sure I am missing some declaration but can't seem to figure out which one that will allow me to use the SqlDataAdapter. Right now it doesn't recognize the SqlDataAdapter. Can anyone please tell me what I am missing? Here are the declarations I have tried.

    <%@ Page Language="vb" AutoEventWireup="false" Codebehind="AddNewPatient.aspx.vb" Inherits="MedSystem.WebForm1"%>
    <%@ Import Namespace="System.Data" %>
    <%@ Import Namespace="System.Data.SqlClient" %>
    <%@ Import Namespace="System.Data.SqlClient.SqlDataAdapter" %>

    Thanks,
    -Kim

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    VB Code:
    1. Imports System.Data.SqlClient

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    5

    Question Any other Ideas???

    Thanks for the reply!

    Unless I am supposed to put it in a different spot. I am already importing that namespace at the top of the HTML that creates the page.

    <%@ Import Namespace="System.Data.SqlClient" %>

    I now have vb behind that form that I want to use to populate my drop down box with and it still won't let me use the SqlDataAdapter stuff.


    Here is my code write now. I get no errors but it won't poplulate the box.

    Code:
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            'Put user code to initialize the page here
            Dim DbConnect As SqlClient.SqlConnection
            Dim strSelect As String
            Dim cmdSelect As SqlClient.SqlCommand
            Dim SuffixReader As SqlClient.SqlDataReader
            Dim ds As New DataSet()
    
            DbConnect = New SqlClient.SqlConnection("server=localhost;UID=sa;Database=medsystem1")
            strSelect = "SELECT SuffixName FROM Suffix"
            cmdSelect = New SqlClient.SqlCommand(strSelect, DbConnect)
            DbConnect.Open()
            SuffixReader = cmdSelect.ExecuteReader
            While SuffixReader.Read()
                cb_Suffix.DataMember = SuffixReader(0)
                cb_Suffix.DataSource() = SuffixReader(0)
                cb_Suffix.DataTextField = SuffixReader(0)
                cb_Suffix.DataValueField = SuffixReader(0)
            End While
            SuffixReader.Close()
            DbConnect.Close()
        End Sub
    Any ideas would be greatly appreciated.
    Thanks,
    -Kim

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    the SQLDataAdapter isn't a namespace, it's an object in the SqlClient namespace.

    Take this line out:
    Code:
    <%@ Import Namespace="System.Data.SqlClient.SqlDataAdapter" %>
    TG
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Try to use SqlCommandBuilder .

  6. #6

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    5

    Thumbs up Figures...my luck!

    Thanks for the reply. I got it now.

    I don't know why but I originally only had the line:

    <%@ Import Namespace="System.Data.SqlClient" %>

    I added the one with the SqlDataAdapter after this line wasn't giving it to me to see if that would work. Now that I took the line out you told me I didn't need it shows up. No clue what I did differently.

    I do have one question from the previous post. For someone who is fairly new to using vb code behind a web page. Is there some easy way to know what declarations I need? Or is there an easy way to tell or look up if something is an object of a class or a class that needs declaring?

    Thanks for the info.

    -Kim

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width