Click here to Skip to main content
15,893,814 members
Home / Discussions / C#
   

C#

 
QuestionData Adapter Column Limits? Pin
Mark T Garcia2-Mar-05 8:00
Mark T Garcia2-Mar-05 8:00 
AnswerRe: Data Adapter Column Limits? Pin
TylerBrinks2-Mar-05 10:37
TylerBrinks2-Mar-05 10:37 
GeneralRe: Data Adapter Column Limits? Pin
Mark T Garcia2-Mar-05 13:21
Mark T Garcia2-Mar-05 13:21 
GeneralRe: Data Adapter Column Limits? Pin
TylerBrinks3-Mar-05 3:56
TylerBrinks3-Mar-05 3:56 
QuestionHow to change text of buttons on MessageBox Pin
oohungoo2-Mar-05 7:39
oohungoo2-Mar-05 7:39 
AnswerRe: How to change text of buttons on MessageBox Pin
Christian Graus2-Mar-05 11:16
protectorChristian Graus2-Mar-05 11:16 
AnswerRe: How to change text of buttons on MessageBox Pin
Yulianto.2-Mar-05 13:32
Yulianto.2-Mar-05 13:32 
Generalpl some one correct the error i got Pin
chandtec2-Mar-05 6:05
chandtec2-Mar-05 6:05 
HI,
Pl coreect the error its real urgebt for me . plzz

near this syntax iam getting error
password = (string)objcom.ExecuteScalar();

ERROR MSG
d:\inetpub\wwwroot\Naveen\WebForm1.aspx.cs(93): The type or namespace name 'objcom' could not be found (are you missing a using directive or an assembly reference?)




Lakshmi Narayanan <laks_win@yahoo.co.in> wrote:

Hi,
Code not tested, so pls chk the spell as well as case sensitive.

[code]
using System.Data.SqlClient;
........
........


private string GetPasswordFromDB(string userName)
{
string password = string.Empty;

//Consider <urtable> is having the fields namely, userId and PWD for
username and password

SqlConnection objCon = new SqlConnection
("server=localhost;database=test;Integrated Security=true");
objCon.Open();
SqlCommand objCom = new SqlCommand("select PWD from <urtable> where
userId = '" + userName + "'",objCon);
password = (string)objcom.ExecuteScalar();
return password;
}
[/code]

Regards
Laks.R

--- In dotnetoffers@yahoogroups.com, mukkasa sai <mukkasasai@y...>
wrote:
> Hai all,
>
> This is the code for login btn c#.net.
>
> my server name is SHAR , WINDOWS AUth in sql server . Pl give me
the code (marked in red i have to implement ado.net code). pl give
me the code
>
> just i have to chk pswd,username & (ck submit)go to main page .
give code to chk & login
>
>
>
> Code Behind
>
> using System;
> using System.Collections;
> using System.ComponentModel;
> using System.Data;
> using System.Drawing;
> using System.Web;
> using System.Web.SessionState;
> using System.Web.UI;
> using System.Web.UI.WebControls;
> using System.Web.UI.HtmlControls;
>
> namespace LoginPage
> {
> ///
> /// Summary description for WebForm1.
> ///

> public class WebForm1 : System.Web.UI.Page
> {
> protected System.Web.UI.WebControls.TextBox txtUserName;
> protected System.Web.UI.WebControls.Button btnLogin;
> protected System.Web.UI.WebControls.Button btnReset;
> protected System.Web.UI.WebControls.Label lblError;
> protected System.Web.UI.WebControls.TextBox txtPassword;
>
> private void Page_Load(object sender, System.EventArgs e)
> {
>
> if(!Page.IsPostBack)
> {
> lblError.Visible=false;
> }
>
> // Put user code to initialize the page here
> }
>
> #region Web Form Designer generated code
> override protected void OnInit(EventArgs e)
> {
> //
> // CODEGEN: This call is required by the ASP.NET Web Form Designer.
> //
> InitializeComponent();
> base.OnInit(e);
> }
>
> ///
> /// Required method for Designer support - do not modify
> /// the contents of this method with the code editor.
> ///

> private void InitializeComponent()
> {
> this.btnLogin.Click += new System.EventHandler
(this.btnLogin_Click);
> this.btnReset.Click += new System.EventHandler
(this.btnReset_Click);
> this.Load += new System.EventHandler(this.Page_Load);
>
> }
> #endregion
>
> private void btnLogin_Click(object sender, System.EventArgs e)
> {
>
> string originalPassword = GetPasswordFromDB
(this.txtUserName.Text.Trim());
> if ((txtUserName.Text != string.Empty) && (txtPassword.Text ==
originalPassword))
> {
> lblError.ForeColor = System.Drawing.Color.Green;
> lblError.Text = "Login Successful";
> lblError.Visible=true;
> }
> else
> {
> lblError.Text = "Invalid User or Password";
> lblError.ForeColor = System.Drawing.Color.Red;
> lblError.Visible=true;
> }
>
> }
>
> private void btnReset_Click(object sender, System.EventArgs e)
> {
> if (lblError.Visible == true)
> lblError.Visible=false;
> this.txtUserName.Text = string.Empty;
> this.txtPassword.Text=string.Empty;
>
> }
> private string GetPasswordFromDB(string userName)
> {
> string password = string.Empty;
> //
> //TODO: Write the logic here to get the password from database
> // using ADO.Net
> //
> return password;
> }
> }
> }
>
>
> HTML
>
> <%@ Page language="c#" Codebehind="WebForm1.aspx.cs"
AutoEventWireup="false" Inherits="LoginPage.WebForm1" %>
>
>
>
> <title>WebForm1
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> <asp:label runat="server" id="lblError" forecolor="#ff3333"
="">Invalid UserId or Password
>
UserName
>
> <asp:textbox id="txtUserName" runat="server">
Password
>
> <asp:textbox id="txtPassword" runat="server"
textmode="Password">
> <asp:button id="btnLogin" runat="server" text="Login">
> <asp:button id="btnReset" runat="server"
text="Reset">

>
>
>
>
GeneralRe: pl some one correct the error i got Pin
Colin Angus Mackay2-Mar-05 6:22
Colin Angus Mackay2-Mar-05 6:22 
GeneralRe: ONE More doubt pl (Colin Angus Mackay) Pin
chandtec2-Mar-05 6:57
chandtec2-Mar-05 6:57 
GeneralRe: ONE More doubt pl Pin
Colin Angus Mackay2-Mar-05 7:03
Colin Angus Mackay2-Mar-05 7:03 
GeneralRe: ONE More doubt pl Pin
chandtec2-Mar-05 7:20
chandtec2-Mar-05 7:20 
GeneralRe: RE KINDLY SEE MY QNS Pin
chandtec2-Mar-05 8:26
chandtec2-Mar-05 8:26 
GeneralRe: colin kindly give me the steps how i shouls proceed to avoid it Pin
chandtec2-Mar-05 10:26
chandtec2-Mar-05 10:26 
GeneralRe: colin kindly give me the steps how i shouls proceed to avoid it Pin
Dave Kreskowiak3-Mar-05 0:46
mveDave Kreskowiak3-Mar-05 0:46 
GeneralRe: colin kindly give me the steps how i shouls proceed to avoid it Pin
chandtec3-Mar-05 16:39
chandtec3-Mar-05 16:39 
QuestionHow to determine if Object obj is a collection or not? Pin
rajesh.net2-Mar-05 5:20
rajesh.net2-Mar-05 5:20 
AnswerRe: How to determine if Object obj is a collection or not? Pin
Colin Angus Mackay2-Mar-05 5:32
Colin Angus Mackay2-Mar-05 5:32 
AnswerRe: How to determine if Object obj is a collection or not? Pin
S. Senthil Kumar2-Mar-05 7:28
S. Senthil Kumar2-Mar-05 7:28 
GeneralLooking for a better way to build a Dataset Pin
Adam °Wimsatt2-Mar-05 5:03
Adam °Wimsatt2-Mar-05 5:03 
GeneralRe: Looking for a better way to build a Dataset Pin
leppie2-Mar-05 6:59
leppie2-Mar-05 6:59 
GeneralRe: Looking for a better way to build a Dataset Pin
Samar Aarkotti2-Mar-05 7:38
Samar Aarkotti2-Mar-05 7:38 
GeneralRe: Looking for a better way to build a Dataset Pin
Peter Vertes2-Mar-05 18:37
Peter Vertes2-Mar-05 18:37 
GeneralC# Application to Web Pin
Samar Aarkotti2-Mar-05 4:42
Samar Aarkotti2-Mar-05 4:42 
GeneralRe: C# Application to Web Pin
Adam °Wimsatt2-Mar-05 5:06
Adam °Wimsatt2-Mar-05 5:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.