i'm having problem vb system i'm developing degree project.
i don't have errors in list have pop message appearing stating "unhandled exception has occurred in application. if click continue, application ignore attempt continue.... "
after pop displays, exe hangs, , exits.
here's code. code meant accept few details admin , save in microsoft access db called cqfos table named adminrecords.
imports system.data.oledb imports system.configuration public class adminadd 'must put everytime, global bro dim con new oledbconnection dim cmd new oledbcommand private sub addadmin_click(byval sender system.object, byval e system.eventargs) handles addadmin.click dim ta new cqfosdataset1tableadapters.adminrecordstableadapter dim cmd new oledbcommand dim con new oledbconnection 'dim yourconnection string = configurationmanager.connectionstrings("yourconnectionstring").connectionstring() dim yourconnection string = configurationmanager.connectionstrings("yourconnectionstring").connectionstring 'con = new oledbconnection(yourconnectionstring) con = new oledbconnection(yourconnection) cmd.commandtype = commandtype.text dim connectionstring string = configurationmanager.connectionstrings("cqfosconnectionstring").connectionstring con = new oledbconnection(connectionstring) cmd.commandtype = commandtype.text cmd.commandtext = "insert adminrecords (adminid,name,dob,gender,address,phoneno,email) values (@adminid, @name,@dob,@gender,@address,@phoneno,@email)" cmd.parameters.addwithvalue("@adminid", adminidtxt.text) cmd.parameters.addwithvalue("@name", nametxt.text) cmd.parameters.addwithvalue("@dob", dobtxt.text) cmd.parameters.addwithvalue("@gender", gendertxt.text) cmd.parameters.addwithvalue("@address", addtxt.text) cmd.parameters.addwithvalue("@phoneno", cnotxt.text) cmd.parameters.addwithvalue("@email", emailtxt.text) cmd.connection = con dim rowsaffected integer con.open() 'rowaffected returns number or row affected rowsaffected = cmd.executenonquery() dim selectquery string = "select adminrecords" if rowsaffected = 1 msgbox("new record saved.", msgboxstyle.okonly, "cqfos") end if con.close() end sub end class
any appreciated. thank in advance.
cmd.commandtext = "insert adminrecords (adminid,name,dob,gender,address,phoneno,email) values (@adminid, @name,@dob,@gender,@phoneno,@address, @email)"
your phoneno , address parameters wrong way round.
Comments
Post a Comment