User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 403,299 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,828 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting

String connection

Join Date: Jan 2005
Posts: 5
Reputation: ABDUL HAYEE is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
ABDUL HAYEE ABDUL HAYEE is offline Offline
Newbie Poster

String connection

  #1  
May 10th, 2008
Hello!
I have just developed, as an assignment , a small conventional website, commonly used for “Log in “purposes. User enters the UserID and password. User ID is compares from the customer Table, to verify, if the name already exists in database. If yes, he is directed to main page.
Else he is directed to newuser Register page , for providing personal information . This information is added in the database table as a new recordset.

The code in index.aspx.vb file is as under.

Imports System.Data.SqlClient

Partial Class index
    Inherits System.Web.UI.Page


    Private Sub Page_Load(ByVal sender As Object, ByVal e As         				System.EventArgs) Handles MyBase.Load

 	End sub 



    Protected Sub Submit_Click(ByVal sender As Object, ByVal e As 	System.EventArgs) Handles Submit.Click
        Session("Name") = txtusername.Text
        Dim con As New  SqlConnection(System.Configuration. 						ConfigurationManager.AppSettings("Zeedb"))

        Dim dr As SqlDataReader
        'Dim StudentID As String
        Dim strSQL As String = "SELECT * FROM  tblCustomer  WHERE 			CustomerName = '" & txtusername.Text & "' and Password = '" 		& txtPassword.Text & "'"
        Dim cmdSQL As SqlCommand
        Try
            con.Open()
            cmdSQL = New SqlCommand(strSQL, con)
            cmdSQL.ExecuteNonQuery()
            dr = cmdSQL.ExecuteReader

            If dr.Read Then
                Response.Redirect("mainpage.aspx")
            Else
                Response.Redirect("index1.aspx")
            End If


        Catch ex As Exception
            lblError.Text = ex.Message
        Finally
            con.Close()
        End Try

    End Sub

    Protected Sub newuser_Click(ByVal sender As Object, ByVal e As 			System.EventArgs) Handles newuser.Click
	        Response.Redirect("register.aspx")
    End Sub
End Class
The Customers file resides in database named “Zeedb “at a Local SQL server in a different directory within the same machine. Web server used is Local Host built-in within the same machine.

The problem I am facing is that when I debug the system, the build up succeeds. However, when data is entered in text boxes (User Name and Password) I receive an error message:

“The ConnectionString property has not been initialized”

As tried to search on MSDN and Google, it seems to be a very common mistake, but I could not find the remedy. The reason of the fault could not be identified.

Please help me pointing out , where is the oversight, which I cannot locate.
Thanks.
Abdul Hayee.
AddThis Social Bookmark Button
Reply With Quote  
All times are GMT -4. The time now is 7:06 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC