c# - member login and read own notes -
i have created website user can become register , log in username / password when log in, can create own notes + (here's problem started> must option can read or see own notes ex on second page.
i confused, maybe guys can me , try different sql statements , different inner join but,nothing happens on page,where users can see own notes after finished create own notes.
my db looks this. 2 table. tbluser (fldid, fldusername, fldpassword) , tblnote (fldid, fldnotes)
my code-behind , sql statements this:
code-behind: createnotes.aspx protected void btncreate_click(object sender, eventargs e) getcontent objnote = new getcontent(); objnote._note = txttext.text; objnote._idnote = convert.toint32(session["userid"]); objnote.addnotes(); litsvar.text = "you have create notes"; response.addheader("refresh", "5; url=createnote.aspx"); } sql statement : public void addnotes() { string strsql = "insert tblnote (fldnote) values(@note)"; sqlcommand cmd = new sqlcommand(strsql); cmd.parameters.addwithvalue("@note", _note); cmd.parameters.addwithvalue("@idnote", _idnote); objdata.modifydata(cmd); } ................ code-behind: usernotes.aspx if (session["userid"] != null) { objdinnote._idnote = convert.toint32(session["userid"]); datatable dtnotes = objdinnote.getnotesbyid(convert.toint32(request.querystring["id"])); foreach (datarow notes in dtnotes.rows) { litsvar.text += notes["fldnote"]; } } sql statement: public datatable getnotesbyid(int _id) { string strsql = ("select tbllogin.*, tblnote.fldnote tbllogin inner join tblnote on tbllogin.fldid = tblnote.fldidnote tbllogin.fldid = @id"); sqlcommand cmd = new sqlcommand(strsql); cmd.parameters.addwithvalue("@id", _id); return objdata.getdata(cmd); }
you don't need join login if know field can directly pass tblnote , related notes
select fldnote tblnote fldid= @id
Comments
Post a Comment