sql - how to query a dataset in c# -
this first post, please gentle :)
i'm working on automatic register university project. use rfid scanner scan student id tag , db created in access. use c# , datagridview show db tables.
i trying write sql query return current sessionid each scanned tagid, compering date/time saved in db current date/time. question is: how do it? have googled problem not find answer looking (probably due complicated structure of tables). maybe able help.
my tables structured followed:
student fields name -> data type ========================= (pk) tagid -> number studentid -> text (fk) courseid -> number studentname -> text course ========================= (pk) courseid -> number coursename -> text coursemodule ========================= (fk) courseid -> number (fk) moduleid -> text module ========================= (pk) moduleid -> text coursename -> text modulesession ========================= (fk) moduleid -> text (fk) sessionid -> text session ========================= (pk) sessionid -> text sessionstartdate -> date sessiontimestart -> time sessiontimeend -> time attendance ========================= (fk) tagid -> number (fk) sessionid -> text (fk) scanningtime -> date/time
i not sure want. here basic database querying c#.
use dataadapters populate datatables sql query.
using (sqlconnection conn = connection) { conn.open(); using (sqlcommand cmd = conn.createcommand()) { cmd.commandtext = @"select * [your tables] tagid = @tagid"; cmd.parameters.add(new sqlparameter("@tagid", sqldbtype.uniqueidentifier) { value = variablename}); using (sqldataadapter adapter = new sqldataadapter(cmd)) { dataset dataset = new dataset(); adapter.fill(dataset, "datatablename"); return dataset.tables["datatablename"]; } } }
then can values datatable looping through or using lambda functions
or can bind datatable gridview using gridview properties
what want datatable not sure.
Comments
Post a Comment