|
-
Jul 17th, 2004, 04:33 PM
#1
Thread Starter
New Member
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
-
Jul 17th, 2004, 06:06 PM
#2
Sleep mode
VB Code:
Imports System.Data.SqlClient
-
Jul 20th, 2004, 11:16 AM
#3
Thread Starter
New Member
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
-
Jul 20th, 2004, 11:22 AM
#4
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
-
Jul 20th, 2004, 12:50 PM
#5
Sleep mode
Try to use SqlCommandBuilder .
-
Jul 20th, 2004, 01:28 PM
#6
Thread Starter
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|