Import namespace
Imports system. Data
Imports system. Data. sqlclient
Private sub page_load (byval sender as system. Object, byval e as system. eventargs) handles mybase. Load
'User code to place the initialization page here
'Dim mydb As DB
If not ispostback then
'Province bound
'Dim connstr as string = "Server =.; database = mag_web; user id = sa; Password = ;"
'Dim myconn as sqlconnection
'Myconn = new sqlconnection (connstr)
'Myconn = mydb. getsqlconn ()
Dim myconn as sqlconnection = myconnection. getsqlconn
Myconn. open ()
Dim mycommand as new sqlcommand ("select * From Province", myconn)
Dim myreader as sqldatareader
Myreader = mycommand. executereader ()
Dropdownlist1.datasource = myreader
Dropdownlist1.datatextfield = "proname"
Dropdownlist1.datavaluefield = "proid"
Dropdownlist1.databind ()
Myreader. Close ()
'Binding City
Dim mycity as new sqlcommand ("select * from city where proid =" + dropdownlist1.selectedvalue, myconn)
Dim myreader1 as sqldatareader
Myreader1 = mycity. executereader ()
Dropdownlist2.datasource = myreader1
Dropdownlist2.datatextfield = "cityname"
Dropdownlist2.datavaluefield = "cityid"
Dropdownlist2.databind ()
Myreader1.close ()
Myconn. Close ()
End if
'Dim myconn as sqlconnection
End sub
Private sub btnreset_click (byval sender as system. Object, byval e as system. eventargs) handles btnreset. Click
Txtusername. Text = ""
Txtpassword1.text = ""
Txtpassword2.text = ""
Requiredfieldvalidator1.visible = false and requiredfieldvalidator2.visible = false
'Comparevalidator1. Visible = false
End sub
Private sub btnsumbit_click (byval sender as system. Object, byval e as system. eventargs) handles btnsumbit. Click
'Dim connstr as string = "Server =.; database = mag_web; user id = sa; Password = ;"
Dim myconn as sqlconnection = myconnection. getsqlconn
'Myconn = new sqlconnection (connstr)
Myconn. open ()
Dim mycommand as new sqlcommand ("insert into mag_users (username, userpassword, userprovince, usercity) values ('" + txtusername. text + "','" + txtpassword1.text + "','" + dropdownlist1.selecteditem. text + "','" + dropdownlist2.selecteditem. text + "')")
Mycommand. Connection = myconn
Mycommand. executenonquery ()
Myconn. Close ()
Response. Redirect ("login2.aspx ")
End sub
Private sub dropdownlistpolicselectedindexchanged (byval sender as system. Object, byval e as system. eventargs) handles dropdownlist1.selectedindexchanged
Dim proid as string
Proid = dropdownlist1.selectedvalue
'Dim connstr as string = "Server =.; database = mag_web; user id = sa; Password = ;"
Dim myconn as sqlconnection = myconnection. getsqlconn
'Myconn = new sqlconnection (connstr)
'Myconn = mydb. getsqlconn ()
Myconn. open ()
Dim mycommand as new sqlcommand ("select * from city where proid =" + proid, myconn)
Dim myreader as sqldatareader
Myreader = mycommand. executereader ()
Dropdownlist2.datasource = myreader
Dropdownlist2.datatextfield = "cityname"
Dropdownlist2.datavaluefield = "cityid"
Dropdownlist2.databind ()
Myreader. Close ()
Myconn. Close ()
End sub