Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Login function

Author  Topic 

MrJx
Starting Member

13 Posts

Posted - 2010-10-24 : 21:22:16
hi all, i am new SQL and aspx ...
i want to create a login function ..
but me dun know how to link to SQL server?/
anyone can teach me??

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-10-24 : 21:27:49
http://www.connectionstrings.com/

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

MrJx
Starting Member

13 Posts

Posted - 2010-10-24 : 22:25:55
choose anyway to do also can ?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-10-24 : 22:27:25
I don't understand your question.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

MrJx
Starting Member

13 Posts

Posted - 2010-10-24 : 22:39:31
Server Error in '/' Application.

Invalid value for key 'attachdbfilename'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: Invalid value for key 'attachdbfilename'.

Source Error:


Line 16: strConn = WebConfigurationManager.ConnectionStrings("ConnectionASPX").ConnectionString
Line 17:
Line 18: Dim Conn As New SqlConnection(strConn)
Line 19: Conn.Open()
Line 20:

Source File: C:\Domains\maroonstudio.com\httpdocs\test\Default.aspx.vb Line: 18

Stack Trace:


[ArgumentException: Invalid value for key 'attachdbfilename'.]
System.Data.SqlClient.SqlConnectionString.VerifyLocalHostAndFixup(String& host, Boolean enforceLocalHost, Boolean fixup) +812668
System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) +2207
System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous) +24
System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(String connectionString, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) +200
System.Data.SqlClient.SqlConnection.ConnectionString_Set(String value) +62
System.Data.SqlClient.SqlConnection.set_ConnectionString(String value) +4
System.Data.SqlClient.SqlConnection..ctor(String connectionString) +24
_Default.Login1_Authenticate(Object sender, AuthenticateEventArgs e) in C:\Domains\maroonstudio.com\httpdocs\test\Default.aspx.vb:18
System.Web.UI.WebControls.AuthenticateEventHandler.Invoke(Object sender, AuthenticateEventArgs e) +0
System.Web.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e) +107
System.Web.UI.WebControls.Login.AttemptLogin() +116
System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +101
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +168
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3436




that is my problem >.<
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-10-24 : 23:08:19
Please post your connection string.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

MrJx
Starting Member

13 Posts

Posted - 2010-10-24 : 23:10:21
<connectionStrings>
<add name="CnnStr" connectionString="Data Source=169.254.6.178\MAROON;Initial Catalog=staff;User ID=****;Password=****"
providerName="System.Data.SqlClient"/>

</connectionStrings>
Go to Top of Page

MrJx
Starting Member

13 Posts

Posted - 2010-10-24 : 23:18:51
Line 19: Conn.Open()
error ~
means cant read the database ?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-10-24 : 23:32:01
Your error is referencing "attachdbfilename". Could you post that portion of code?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

MrJx
Starting Member

13 Posts

Posted - 2010-10-24 : 23:42:47
sure can...

aspx.vb

Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.Configuration
Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles Login1.Authenticate
Dim username As String
Dim pwd As String
Dim pName As String

username = Login1.UserName
pwd = Login1.Password
pName = ""
Dim strConn As String
strConn = WebConfigurationManager.ConnectionStrings("ConnectionASPX").ConnectionString

Dim Conn As New SqlConnection(strConn)
Conn.Open()


Dim sqlUserName As String
sqlUserName = "SELECT ID,PW FROM staffInfor "
sqlUserName &= " WHERE (ID = @ID"
sqlUserName &= " AND PW = @PW)"

Dim com As New SqlCommand(sqlUserName, Conn)
com.Parameters.AddWithValue("@ID", username)
com.Parameters.AddWithValue("@PW", pwd)


Dim CurrentName As String
CurrentName = CStr(com.ExecuteScalar)

If CurrentName <> "" Then
Session("UserAuthentication") = username

Response.Redirect("About.aspx")
Else
Session("UserAuthentication") = ""
End If

End Sub
End Class





aspx

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>login</title>
</head>
<body>
<form id="form1" runat="server">
<div>

<asp:Login ID="Login1" runat="server" BackColor="#FFFBD6" BorderColor="#FFDFAD" BorderPadding="4"
BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em"
ForeColor="#333333" OnAuthenticate="Login1_Authenticate" TextLayout="TextOnTop"
Width="293px"
Height="172px">
<TitleTextStyle BackColor="#990000" Font-Bold="True" Font-Size="0.9em"
ForeColor="White" />
<InstructionTextStyle Font-Italic="True" ForeColor="Black" />
<TextBoxStyle Font-Size="0.8em" />
<LoginButtonStyle BackColor="White" BorderColor="#CC9966" BorderStyle="Solid" BorderWidth="1px"
Font-Names="Verdana" Font-Size="0.8em" ForeColor="#990000" />
</asp:Login>

</div>
</form>
</body>
</html>
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-10-24 : 23:49:36
I don't see it in the code. As your problem is with your application and not with SQL Server, I'd recommend posting your question on a VB.NET/asp.net forum. Try www.asp.net for many .NET forums.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

MrJx
Starting Member

13 Posts

Posted - 2010-10-25 : 00:18:47
eh?!? when i create it i use New Web site ??
or should use new project ??
Go to Top of Page

MrJx
Starting Member

13 Posts

Posted - 2010-10-25 : 07:00:20
anyone least can help me ? >.<
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-10-25 : 07:47:04
quote:
Originally posted by MrJx

eh?!? when i create it i use New Web site ??
or should use new project ??



I think you need to get some training or work through a basic tutorial on ASP.net/VB.net

--
Gail Shaw
SQL Server MVP
Go to Top of Page
   

- Advertisement -