Asp.net and connecting my database

andycharger

Well-known member
Joined
Apr 2, 2003
Messages
152
Hi.

Im just taking my first steps with .net and im building a web based application. I need to hooc up to my sql server 2000 db from my application. I can see the database in the left hand window and the connection all works.

However,

I see that you use namespaces to import the classes.

Can someone tell me why the namespace is not "intellisensing" when I start typing "System.Data.SqlClient"?

I will include my longon page code to ask why I should put this.

If someone could provide a simple example as to how I get to my data, I would be forever grateful.

Andy

Code:
Public Class logon

    Inherits System.Web.UI.Page

    Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
    Protected WithEvents Button1 As System.Web.UI.WebControls.Button
    Protected WithEvents TextBox2 As System.Web.UI.WebControls.TextBox
    Protected WithEvents Label2 As System.Web.UI.WebControls.Label
    Protected WithEvents Label1 As System.Web.UI.WebControls.Label

#Region " Web Form Designer Generated Code "

    This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        CODEGEN: This method call is required by the Web Form Designer
        Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    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
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim da As sqlDataAdapter = New sqlDataAdapter()

        Dim strUsername As String
        Dim strPW As String

        strUsername = TextBox1.Text
        strPW = TextBox2.Text

        Dim strOleDb As String
        Dim cnOleDb As New OleDBConnection()



    End Sub

End Class
 
You need to Reference the SqlClient as well as ...(at the top of the code page)
Imports System.Data
Imports System.Data.SqlClient
 
Where abouts?

Can you tell me where?
I tried adding the imports bit into the top bit where it says Inherits but it does not pick up the intellisense.
I added it into the References for the Project and it worked to a point. It does not like ExecuteReader.
 
What are your references (in the project)? You should have System.Data at a minimum for this to work. Then having the right Imports statements should do the trick.

Check the object browser (ctrl-alt-J) to see what libraries you have available. It pulls from whatever youve got referenced in the solution explorer.

-Nerseus
 
Back
Top