3 Replies - 2701 Views - Last Post: 06 May 2013 - 09:03 AM Rate Topic: -----

#1 azeem abbas  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 9
  • Joined: 13-December 12

asp.net with c# in visual studio 2010

Posted 05 May 2013 - 03:08 PM

I am making my project in asp.net with c# using visual studio 2010 and this is my aspx code
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="MySolution.Login" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="FullWidth" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">

<form id="form1" runat="server">
                    <div class="post">
						<h1 class="post-title">Login</h1>
						<div class="post-content">
                            <br/>
							<asp:label for="username" runat="server">Username: </asp:label><br/>
                            <asp:TextBox ID="username" type="text" name="username" runat="server"></asp:TextBox>
                           <!-- <input type="text" name="username" id="username"/>!--><br/>

							<asp:label for="password" runat="server">Password: </asp:label><br/>
                             <asp:TextBox ID="password" type="text" name="password" runat="server"></asp:TextBox>
							<!--<input type="text" name="password" id="password"/>!--><br/>

					 <asp:Label ID="LabelInvalidusermsg" runat="server" ForeColor="Red" 
                Text="Invalid User Name or Password" Visible="False"></asp:Label> 

                            <asp:Button ID="user_login" type="submit"  runat="server" Text="Login" 
                                onclick="user_login_Click"   />
						</div>
                        </div>
                        </form>
					
</asp:Content>


and i want to insert an login data in the database what should i do

This post has been edited by macosxnerd101: 06 May 2013 - 08:38 AM
Reason for edit:: Please use code tags


Is This A Good Question/Topic? 0
  • +

Replies To: asp.net with c# in visual studio 2010

#2 rgfirefly24  Icon User is offline

  • D.I.C Lover
  • member icon


Reputation: 267
  • View blog
  • Posts: 1,470
  • Joined: 07-April 08

Re: asp.net with c# in visual studio 2010

Posted 06 May 2013 - 07:31 AM

1. Figure out what database you want to use, create the needed TABLES to store the data
2. Create a Connection object to said database. Either OLEDBConnection or SQLConnection
3. Create a Command Object and setup the parameters with it. either OLEDBCommand or SQLCommand
4. In one of said parameters you will use an INSERT statement to INSERT the data into your TABLE that will hold log in data

Take the above steps, attempt to do it yourself, and if you have any problems come back with specifics and the supporting errors/code and we can help you then. We do not and will not write your code for you.
Was This Post Helpful? 0
  • +
  • -

#3 azeem abbas  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 9
  • Joined: 13-December 12

Re: asp.net with c# in visual studio 2010

Posted 06 May 2013 - 08:55 AM

View Postrgfirefly24, on 06 May 2013 - 07:31 AM, said:

1. Figure out what database you want to use, create the needed TABLES to store the data
2. Create a Connection object to said database. Either OLEDBConnection or SQLConnection
3. Create a Command Object and setup the parameters with it. either OLEDBCommand or SQLCommand
4. In one of said parameters you will use an INSERT statement to INSERT the data into your TABLE that will hold log in data

Take the above steps, attempt to do it yourself, and if you have any problems come back with specifics and the supporting errors/code and we can help you then. We do not and will not write your code for you.


Actually i want to do do it through stored procedure method that when the user enter the login and password the query runs and check the login and password and login the user what should code statements should i use in login.aspx.cs file
Was This Post Helpful? 0
  • +
  • -

#4 rgfirefly24  Icon User is offline

  • D.I.C Lover
  • member icon


Reputation: 267
  • View blog
  • Posts: 1,470
  • Joined: 07-April 08

Re: asp.net with c# in visual studio 2010

Posted 06 May 2013 - 09:03 AM

So that is completely different then what you said Originally.

To do that I would take the username and password provided from the user and pass it into your stored procedure and then either use the return value as the mechanism to say if they are authed, or SELECT their role and check that to see what they have.

So you would set the Command object's CommandType property as stored procedure and set the Parameters of the command object aswell.

1. create the command object like so: SqlCommand cmd = new SqlCommand("Procedure Name",con);
2. Set the Command Type property like so: cmd.CommandType = CommandType.StoredProcedure
3. Set the command's Paramters with the .Parameters.AddWithValue() like so cmd.Parameters.AddWithValue("ParameterName",ParamterValue);
4. From there execute the command with one of the execute statements probably either executereader or executescalar.

This post has been edited by rgfirefly24: 06 May 2013 - 09:04 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1