| 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 |
|
|
MrJx
Starting Member
13 Posts |
Posted - 2010-10-24 : 22:25:55
|
| choose anyway to do also can ? |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
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").ConnectionStringLine 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) +3436that is my problem >.< |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
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> |
 |
|
|
MrJx
Starting Member
13 Posts |
Posted - 2010-10-24 : 23:18:51
|
| Line 19: Conn.Open()error ~means cant read the database ? |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
MrJx
Starting Member
13 Posts |
Posted - 2010-10-24 : 23:42:47
|
| sure can...aspx.vbImports System.DataImports System.Data.SqlClientImports System.Web.ConfigurationPartial 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 SubEnd Classaspx<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> |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
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 ?? |
 |
|
|
MrJx
Starting Member
13 Posts |
Posted - 2010-10-25 : 07:00:20
|
| anyone least can help me ? >.< |
 |
|
|
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 ShawSQL Server MVP |
 |
|
|
|