sql - How to Copy a table row details to visual studio form -



sql - How to Copy a table row details to visual studio form -

i have table seek - "uid,pwd,mob , name."

cl001 abc 9876589 admin cl002 def 8909898 admin2

i want phone call values in visual basic form table , display values in corresponding textbox .i know sql query --> select * seek uid="cl001"

here function allow execute select statement on database. before phone call must declare new datatable like:

dim dt new datatable dt = dosql("select * seek uid='cl001'") public function dosql(byval sqlcmd string) datatable dim cmd new sql.sqlcommand() dim cnn new sql.sqlconnection(my.settings.cnnstring) ' connection string here dim sqldt new datatable cmd .connection = cnn .commandtext = sqlcmd .commandtype = commandtype.text end dim da new sql.sqldataadapter() da.selectcommand = cmd da.fill(sqldt) homecoming sqldt end function

the datatable have records match. if know there going 1 record like:

textbox.text = dt.rows(0).item("uid").tostring

or bind textbox , utilize bindingmanagerbase maintain track of position like:

private withevents bm bindingmanagerbase ' class scope private sub partbind(byval dt datatable) txtbox.databindings.add("text", dt, "uid") end sub

you can command flipping through record bm.position so:

private sub btnnavclick(byval sender system.object, byval e system.eventargs) handles btnnext.click, btnprevious.click, btnlast.click, btnfirst.click dim btnclicked button = directcast(sender, button) select case btnclicked.name case "btnnext" if bm.position < bm.count - 1 bm.position += 1 else bm.position = 0 end if case "btnprevious" if bm.position > 0 bm.position -= 1 else bm.position = bm.count end if bm.position -= 0 case "btnlast" bm.position = bm.count case "btnfirst" bm.position = 0 end select end sub

sql vb.net

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -