Advertisement

07.18.2008 at 03:10AM PDT, ID: 23576295
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.3

having problom with sqlConnection to databse for my login form.....getting error message.

Asked by gonadn in Web Languages/Standards, Programming for ASP.NET, Microsoft Visual C#.Net

Tags:

hi

i get error message :Documents\LaPaz\login1.aspx.cs:line 121Error Connecting to the database.....iam new to asp.net programming, i nedd help to make a secure login system for my shoppingchart on my webpage...can somone help me come throw this issue...?1

Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
DBConnection function:
 
private bool DBConnection(string txtUser, string txtPass)
    {
        SqlConnection myConn = new SqlConnection(ConfigurationSettings.AppSettings["strConn"]);
        SqlCommand myCmd = new SqlCommand("sp_ValidateUser", myConn);
        
 
        myCmd.CommandType = CommandType.StoredProcedure;
 
        SqlParameter objParam1;
        SqlParameter objParam2;
        SqlParameter returnParam;
 
        objParam1 = myCmd.Parameters.Add("@UserName", SqlDbType.VarChar);
        objParam2 = myCmd.Parameters.Add("@Password", SqlDbType.VarChar);
        returnParam = myCmd.Parameters.Add("@Num_of_User", SqlDbType.Int);
 
        objParam1.Direction = ParameterDirection.Input;
        objParam2.Direction = ParameterDirection.Input;
        returnParam.Direction = ParameterDirection.ReturnValue;
 
        objParam1.Value = txtUser;
        objParam2.Value = txtPass;
 
        try
        {
            if (myConn.State.Equals(ConnectionState.Closed))
            {
                myConn.Open();
                myCmd.ExecuteNonQuery();
            }
            if ((int)returnParam.Value < 1)
            {
                lblMessage.Text = "Invalid Login!";
                return false;
            }
            else
            {
                myConn.Close();
                return true;
            }
        }
        catch (Exception ex)
        {
            lblMessage2.Text = ex + "Error Connecting to the database";
            
            return false;
        }
 
    
  }
 
**************Web.Config************************
 
<?xml version="1.0"?>
<!-- 
    Note: As an alternative to hand editing this file you can use the 
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in 
    machine.config.comments usually located in 
    \Windows\Microsoft.Net\Framework\v2.x\Config 
-->
<configuration>
  <appSettings>
    <add key="strConn" value="Network Library=DBMSSOCN;Data Source=(local),1433;database=LaPaz;User id=;Password=;"/>
  </appSettings>
 
 
  <connectionStrings>
    <add name="MyMembershipConnString" connectionString="Server=(local);Integrated Security=SSPI;Database=LaPaz" providerName="System.Data.SqlClient"/>
  </connectionStrings>
 
 
  <system.web>
    <!--<smtpMail serverName="MyServer" serverPort="15" from="gonadn@gmail.com">
      <fields>
        <add name="smtpauthenticate" value="2">
        </fields>
    </smtpMail>-->
 
 
    <compilation debug="true"/>
    <!--
            The <authentication> section enables configuration 
            of the security authentication mode used by 
            ASP.NET to identify an incoming user. 
        -->
    <roleManager enabled="true" defaultProvider="MySqlProvider" cacheRolesInCookie="true" cookieName=".MyRolesCookie" cookieTimeout="30" cookieSlidingExpiration="true" cookieProtection="All">
      <providers>
        <add name="MySqlProvider"
        type="System.Web.Security.SqlRoleProvider"
        connectionStringName="MyMembershipConnString"
        applicationName="RolesDemo"/>
      </providers>
    </roleManager>
 
 
      <authentication mode="Forms"/>
      <authorization>
        <allow users="comma-separated list of users"
        roles="comma-separated list of roles"
        verbs="comma-separated list of verbs" />
        <deny users="comma-separated list of users"
        roles="comma-separated list of roles"
        verbs="comma-separated list of verbs" />
      </authorization>
 
 
      <membership>
        <providers>
          <remove name="AspNetSqlMembershipProvider" />
          <add name="AspNetSqlMembershipProvider"
                    type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
                    connectionStringName="MyMembershipConnString"
                    enablePasswordRetrieval="false"
                    enablePasswordReset="true"
                    requiresQuestionAndAnswer="false"
                    applicationName="/"
                    requiresUniqueEmail="false"
                    minRequiredPasswordLength="6"
                    minRequiredNonalphanumericCharacters="0"
                    passwordFormat="Hashed"
                    maxInvalidPasswordAttempts="5"
                    passwordAttemptWindow="10"
                    passwordStrengthRegularExpression="" />
        </providers>
 
 
      </membership>
 
    <!--<smtpMail serverName="local" serverPort="15" from="proaspnet2@apress.com">
    <fields>
      <add name="smtpauthenticate" value="2">
      </add>
      </fields>
    </smtpMail>-->
    </system.web>
</configuration>
 
Loading Advertisement...
 
[+][-]07.18.2008 at 03:14AM PDT, ID: 22034239

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.18.2008 at 03:41AM PDT, ID: 22034338

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.18.2008 at 08:54AM PDT, ID: 22037132

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Web Languages/Standards, Programming for ASP.NET, Microsoft Visual C#.Net
Tags: c# .Net ASP.Net
Sign Up Now!
Solution Provided By: zell71
Participating Experts: 2
Solution Grade: B
 
 
[+][-]07.25.2008 at 04:30AM PDT, ID: 22087495

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628