TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
aditya immadi
NA
205
71.9k
Abou Ado.net
Jul 6 2013 4:51 PM
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
public partial class Admin : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnadminmlogin_Click1(object sender, EventArgs e)
{
string constring = ConfigurationManager.ConnectionStrings["conn"].ToString();
SqlCommand cmd = new SqlCommand();
SqlConnection conn = new SqlConnection(constring);
cmd.Connection = conn;
conn.Open();
cmd.CommandText = "spadmin2";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("name", txtnameadmin.Text);
cmd.Parameters.AddWithValue("password", txtpwdadmin.Text);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
if (ds != null && ds.Tables.Count > 0)
{
string status = ds.Tables[0].Rows[0][0].ToString();
if (status == "yes")
{
Session["name"] = ds.Tables[1].Rows[0]["name"].ToString();
Session["password"] = ds.Tables[1].Rows[0]["password"].ToString();
Response.Redirect("adminhome.aspx");
}
else
{
lblmsg.Text = "ivalid credentials";
}
}
this is my .CS code
and my Db is
create table admin
(
name varchar(50),
password varchar(50),
)
select * from admin
insert into admin (name,password)values('varun','varun123')
create proc spadmin2
(
@name varchar(50),
@password varchar(50)
)
as
begin
if exists (select * from admin where name=@name and password=@password )
begin
select 'yes' as status
end
else
begin
select 'no' as status
end
end
and my error is in this line...it says "
Cannot find table 1."
Session["name"] = ds.Tables[1].Rows[0]["name"].ToString();
can any one help me out
Thanks & Regards
Reply
Answers (
3
)
Problem in using Response objects in c# windows application
Setting original size of an image in Data grid view