sql server - How to retrieve values in textbox and datagridview -
i want display records in textbox
, put records in datagridview
.
store procedure code
select sh.schoolyear, sh.levels,sh.section, sh.dateenrolled latestdate , si.studentid,si.surname,si.firstname,si.middlename, si.studaddress , si.birthday,si.gender, si.nationality, si.birthplace, si.telnum,si.schoolwheregraduated , si.dateswhengraduated, si.schoollastattended, si.schooladdress, si.note,si.studimage, pi.father_firstname,pi.father_lastname, pi.father_mi,pi.father_occupation, pi.father_telnum, pi.mother_firstname, pi.mother_lastname, pi.mother_mi,pi.mother_occupation,pi.mother_telnum, pi.contact_firstname,pi.contact_lastname,pi.contact_mi, pi.contact_mobile,pi.contact_telnum,pi.contact_address studentinformation si join studenthistory sh on si.studentid = sh.studentid join parentinformation pi on pi.parentid = si.parentid si.studentid = @studid order dateenrolled desc
vb.net code
cmd = new sqlcommand("uspstudents", cn) cmd.parameters.addwithvalue("@studid", frmview.dgv1.selectedcells(0).value) cmd.commandtype = commandtype.storedprocedure da.selectcommand = cmd da.fill(dt) cboschoolyear.text = dt.rows(0)("schoolyear").tostring cbosection.text = dt.rows(0).item("section").tostring cbogradelevel.text = dt.rows(0).item("levels").tostring dtpenrollment.text = dt.rows(0).item("latestdate").tostring txtstudln.text = dt.rows(0)("surname").tostring txtstudfn.text = dt.rows(0)("firstname").tostring txtstudmn.text = dt.rows(0)("middlename").tostring txtaddress.text = dt.rows(0)("studaddress").tostring dtpbirthday.text = dt.rows(0)("birthday").tostring cbonationality.text = dt.rows(0)("nationality").tostring txtplaceofbirth.text = dt.rows(0)("birthplace").tostring txtstudentcp.text = dt.rows(0)("telnum").tostring txtswg.text = dt.rows(0)("schoolwheregraduated").tostring dtpdwg.text = dt.rows(0)("dateswhengraduated").tostring txtsla.text = dt.rows(0)("schoollastattended").tostring txtschooladdress.text = dt.rows(0)("schooladdress").tostring txtnote.text = dt.rows(0)("note").tostring txtfathergn.text = dt.rows(0)("father_firstname").tostring txtfathermi.text = dt.rows(0)("father_mi").tostring txtfatherln.text = dt.rows(0)("father_lastname").tostring txtfatheroccupation.text = dt.rows(0)("father_occupation").tostring txtfathercp.text = dt.rows(0)("father_telnum").tostring txtmothergn.text = dt.rows(0)("mother_firstname").tostring txtmotherln.text = dt.rows(0)("mother_lastname").tostring txtmothermi.text = dt.rows(0)("mother_mi").tostring txtmotheroccupation.text = dt.rows(0)("mother_occupation").tostring txtmothercp.text = dt.rows(0)("mother_telnum").tostring txtcontactgn.text = dt.rows(0)("contact_firstname").tostring txtcontactln.text = dt.rows(0)("contact_lastname").tostring txtcontactmi.text = dt.rows(0)("contact_mi").tostring txtcontactaddress.text = dt.rows(0)("contact_address").tostring txtcontactcp.text = dt.rows(0)("contact_mobile").tostring txtcontacttelnum.text = dt.rows(0)("contact_telnum").tostring
displaying of data in textbox
works problem in datagridview
. have tried put code inside vb.net code
dgvhistory.datasource = dt
but displays data in records, want display schoolyear
,section
, levels
in datagridview
. can me solve problem. thanks
you need create columns manually datagridview. -
dgvhistory.columncount = 3 dgvhistory.autogeneratecolumns = false dgvhistory.columns(0).name = "schoolyear" dgvhistory.columns(0).datapropertyname = "schoolyear" dgvhistory.columns(1).name = "section" dgvhistory.columns(1).datapropertyname = "section" dgvhistory.columns(2).name = "levels" dgvhistory.columns(2).datapropertyname = "levels" dgvhistory.datasource = dt
Comments
Post a Comment