•
•
•
•
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 426,442 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 2,245 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
Views: 3464 | Replies: 6
![]() |
•
•
Join Date: Jun 2005
Posts: 19
Reputation:
Rep Power: 4
Solved Threads: 0
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
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
•
•
Join Date: Jun 2005
Posts: 19
Reputation:
Rep Power: 4
Solved Threads: 0
•
•
•
•
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
![]() |
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
.net access adsl adsl1 adsl2 adsl2+ ajax architecture asp backup business cable code combo connection custom daniweb data database development dom download dropdownlist enterprise hacker internet kb kbps linux mbit microsoft module net network news per reuse second security server skin software sql survey testing theme upload web windows 240000
- Connecting to SQL server DB from VB.NET app (VB.NET)
- Sql server connection using code in VB.NET (VB.NET)
- VB.Net and sql server connection (VB.NET)
- SQL Server connection with WEB (Software Developers' Lounge)
- Error in creating ODBC connection."Reason: Not assosiated with a trusted SQL Server" (ASP)
- About Mssql Server connection (MS SQL)
- Problem with URL access to SQL Server 2000 db (RSS, Web Services and SOAP)
Other Threads in the ASP.NET Forum
- Previous Thread: Compilation Error Handles cmdLogin.ServerClick
- Next Thread: accessing common user-defined functions


Linear Mode