hi every one
i have a problem with my program
the problem is cant make a chek if the account is exist or not in the data base (for login the web site)
the error message is:
The ConnectionString property has not been initialized.
here is my code
Imports System.Data.SqlClient
Public Class home
Inherits System.Web.UI.Page
Dim cnn As New SqlConnection(ConfigurationSettings.AppSettings("cnnstr"))
Dim cmd As New SqlCommand
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
cmd.Connection = cnn
End Sub
Private Sub regb_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles regb.Click
Response.Redirect("register.aspx")
End Sub
Private Sub loginb_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles loginb.Click
If usern.Text.Trim.Length > 0 And pass.Text.Trim.Length > 0 Then
If found_Cust() = True Then
Session("CID") = usern.Text.Trim
Session("Flag") = 0
Response.Redirect("login.aspx")
Else
Wlbl.Text = "Incorrect User Name Or Password "
End If
Else
Wlbl.Text = "You Must Enter More Information"
End If
End Sub
Function found_Cust() As Boolean
cmd.CommandText = (" select count(*) from reg where username = '" & usern.Text.Trim & "' and Password = '" & pass.Text.Trim & "'")
cnn.Open()
If cmd.ExecuteScalar = 0 Then
cnn.Close()
Return False
Else
cnn.Close()
Return True
End If
End Function
End Class
and i write this statemernt in web conf.
<appSettings>
<add key="workstation" value="data source=shadid;
User ID=admin;initial catalog=sh;persist security info=False;packet size=4096"/>
</appSettings>
please tell me whats the problem
thank you