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
Asyraf MN
NA
28
7.6k
How to display lucky draw result on a table
Apr 22 2018 8:21 PM
Hi, currently i'm working on lucky draw system. My system are functioning well but i just want to add one features that is it can display a lucky draw result on a table in another page at the same time. Previously, when user click on button draw at the system, it will display out the result at the page. So, how to make the result display on table in another page at the same time when user click button draw?
This is my lucky draw code :
using
System;
using
System.Collections.Generic;
using
System.Configuration;
using
System.Data;
using
System.Data.SqlClient;
using
System.IO;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
public
partial
class
_Default : System.Web.UI.Page
{
string
constr = ConfigurationManager.ConnectionStrings[
"lucky"
].ConnectionString;
protected
void
Page_Load(
object
sender, EventArgs e)
{
}
static
List<
string
> list =
new
List<
string
>();
protected
void
Button1_Click(
object
sender, EventArgs e)
{
string
query =
"SELECT TOP 1[Emp_id]FROM Emp_Info WHERE[Attendance] = 'Present'ORDER BY NEWID()"
;
using
(SqlConnection con =
new
SqlConnection(constr))
{
using
(SqlCommand cmd =
new
SqlCommand(query))
{
using
(SqlDataAdapter sda =
new
SqlDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
using
(DataTable dt =
new
DataTable())
{
sda.Fill(dt);
if
(dt.Rows.Count > 0)
{
if
(list.Any(x => x.Equals(dt.Rows[0][
"Emp_id"
].ToString())))
{
//Label1.Text += "is duplicate";
}
else
{
list.Add(dt.Rows[0][
"Emp_id"
].ToString());
Label1.Text = dt.Rows[0][
"Emp_id"
].ToString();
}
}
else
{
Label1.Text +=
"Cannot draw! "
;
}
}
}
}
}
}
}
Reply
Answers (
0
)
when i add new column in my sql server 2014 Table..Visual c#
How to session clear ?