vb.net - Connect Visual Basic's ComboBox with Access's tables -



vb.net - Connect Visual Basic's ComboBox with Access's tables -

i'm working on visual basic express 2010 , microsoft access. made database , relationships access, connected them vb fine. problem is, have table called address_table, contains 1 field called address_name. table address_table connected the_student table field called student_address "enforce referential integrity".

i can't upload images i'm sorry, tried.

problem #1 is: in visual basic, want create combobox user take choices imported address_name , after clicks on add together button, selection added database student_address field. mean, address_name contains values a, b, c. want these values appear in combobox , after chooses 1 of them, click add together , selection inserted in database.

problem #2 is: ah sorry it's combobox. it's 2 comboboxes when take first 1 table country, take america, in other combobox america's states appear. or when take england, england's cities appear , on.

*table country have 1 field named: country_name. *table scholarship contains field: scholarship_to, country_name, city_name *table city have fileds: city_name, country

*table scholarship , country both connected table named student_info, country connected abc field , scholarship new field. *table country connected scholarship , city tables next fields: country_name in scholarship , country in city table. *scholarship table connected city table: city_name country fields. have "enforce referential integrity".

oh god hope understands me, tried provide everything, please help me.

public class frmstudent dim cnn new oledb.oledbconnection private sub refreshdata() if not cnn.state = connectionstate.open 'open connection cnn.open() end if dim da new oledb.oledbdataadapter("select student_id [id], " & _ "student_name [name], student_gender, student_phone, student_address " & _ " the_student order student_id", cnn) dim dt new datatable 'fill info datatable da.fill(dt) 'offer info in info table datagridview me.dgvdata.datasource = dt 'close connection cnn.close() end sub private sub btnadd_click(byval sender system.object, byval e system.eventargs) handles btnadd.click dim cmd new oledb.oledbcommand if not cnn.state = connectionstate.open 'open connection if not yet open cnn.open() end if cmd.connection = cnn 'check whether add together new or update if me.txtstdid.tag & "" = "" 'add new 'add info table cmd.commandtext = "insert the_student(student_id, student_name, student_gender, student_phone)" & _ " values(" & me.txtstdid.text & ",'" & me.txtstdname.text & "','" & _ me.cbogender.text & "','" & me.txtphone.text & "')" cmd.executenonquery() else 'update info in table cmd.commandtext = "update the_student " & _ " set student_id=" & me.txtstdid.text & _ ", student_name='" & me.txtstdname.text & "'" & _ ", student_gender='" & me.cbogender.text & "'" & _ ", student_phone='" & me.txtphone.text & "'" & _ ", student_address='" & me.txtaddress.text & "'" & _ " student_id=" & me.txtstdid.tag cmd.executenonquery() end if 'refresh info in list refreshdata() 'clear form me.btnclear.performclick() 'close connection cnn.close() end sub private sub frmstudent_load(byval sender object, byval e system.eventargs) handles me.load cnn = new oledb.oledbconnection cnn.connectionstring = "provider=microsoft.jet.oledb.4.0; info source=" & application.startuppath & "\data.mdb" ' 'get info list me.refreshdata() end sub

this has looking for. these referred look-up lists. http://msdn.microsoft.com/en-us/vstudio/bb466226.aspx#formsoverdata

so, in particular, video #5 should 1 looking for. since using vb + access, recommend abandon oledb commands , utilize typed datasets , adapters, etc, unless have compelling reason not to. if do, building lookups out way in these videos generate insert/update/delete statements satisfy constraints (they properties of adapters).

vb.net ms-access combobox

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -