how to make search in sql database in asp.net using C#?
hi i have a table like this for attendence:
table name attendence.
id
std_rolNum
std_fname
date
std_bkfast
std_lunch
std_dinner
i want to make search on the base of date, std_rolnum, std_lunch, std_bkfast and std_dinner.
so that if on the same date if student have already taken breakfast, lunch or dinner he couldn't mark attendence.
so i have to select multiple columns like date and roll_number.
but i couldn't implement my logic in to c#....
2
Contributors
2
Replies
3 Hours
Discussion Span
5 Months Ago
Last Updated
4
Views
Question Answered
Related Article:Insert into sql database
is a solved ASP.NET discussion thread by requiem2 that has 4 replies and was last updated 11 months ago.
thenx JorgeM for your reply. actually i have the following in c#:
SqlConnection conn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=c:\users\shahaiali\documents\visual studio 2010\Projects\apps\Database1.mdf;Integrated Security=True;User Instance=True");
string sql = @"select * from myTable where id = 3 ";
string str;
conn.Open();
SqlDataAdapter da = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
da.Fill(ds, "myTable");
DataTable dt = ds.Tables["myTable"];
foreach (DataRow row in dt.Rows)
{
str = Convert.ToString(row["fName"]);
if (str == "")
{
Console.WriteLine("invalid");
}
else
{
Console.WriteLine(str);
}
in my above scnario the condition is true mean there is no entry against the id 3. as the condition is true it couldn't enter to the block for empty value.