944,146 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 4851
  • ASP.NET RSS
Jun 17th, 2005
0

problem with connection to sql server

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
fineline is offline Offline
19 posts
since Jun 2005
Jun 18th, 2005
0

Re: problem with connection to sql server

Try something like this..
Dim cnn as Sqlconnection
cnn = New SqlConnection(ConfigurationSettings.AppSettings("cnnstr"))
Reputation Points: 11
Solved Threads: 6
Junior Poster
Letscode is offline Offline
175 posts
since Feb 2005
Jun 18th, 2005
0

Re: problem with connection to sql server

You got two things to keep in mind for Sqlconnection
1.Declare...Dim cnn as Sqlconnection
2.Initilize it..cnn = New SqlConnection(ConfigurationSettings.AppSettings("cnnstr"))
Reputation Points: 11
Solved Threads: 6
Junior Poster
Letscode is offline Offline
175 posts
since Feb 2005
Jun 18th, 2005
0

Re: problem with connection to sql server

Quote originally posted by Letscode ...
You got two things to keep in mind for Sqlconnection
1.Declare...Dim cnn as Sqlconnection
2.Initilize it..cnn = New SqlConnection(ConfigurationSettings.AppSettings("cnnstr"))

thank you Letscode but its also didnt work i dont whats the problem plz check the code again and tell me any another code is error or wrong

thank you again
iam waiting your message
Reputation Points: 10
Solved Threads: 0
Newbie Poster
fineline is offline Offline
19 posts
since Jun 2005
Jun 18th, 2005
0

Re: problem with connection to sql server

Can you copy and paste the error code...
Reputation Points: 11
Solved Threads: 6
Junior Poster
Letscode is offline Offline
175 posts
since Feb 2005
Jun 18th, 2005
0

Re: problem with connection to sql server

I need to know where exactly the error is being displayed....
Reputation Points: 11
Solved Threads: 6
Junior Poster
Letscode is offline Offline
175 posts
since Feb 2005
Jun 18th, 2005
0

Re: problem with connection to sql server

Quote originally posted by Letscode ...
I need to know where exactly the error is being displayed....

THANK YOU VERY MUCH AGAIN
NOW... ITS WORK
Reputation Points: 10
Solved Threads: 0
Newbie Poster
fineline is offline Offline
19 posts
since Jun 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Compilation Error Handles cmdLogin.ServerClick
Next Thread in ASP.NET Forum Timeline: accessing common user-defined functions





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC