dim con as new sqlconnection
dim com as new sqlcommand
dim tr as sqltransaction
dim sb as new stringbuider
dim strCon as string
dim strSql as string
private sub ConnectionAccess()
strCon = "Provider=Microsoft.Jet.OLEDB.4.0;;Data Source=C:\\committee.mdb;Jet OLEDB:Database Password="
if con.state = con.open() then con.close()
con.connectionstring = strCon
con.open()
end if
end sub
private sub CommandData()
ConnectionAccess()
tr = con.begintransaction()
try
select case actionflag
case "Add"
sb.remove(0,sb.lenght)
sb.append("insert into committee (committee_id,memberid,password,level)")
sb.append(" values('" & txtcommit_id.text & "',")
sb.append("'" & txtmemberid.text & "',")
sb.append("'" & txtpassword.text & "',")
sb.append("'" & txtlevel.text & "')")
strSql = sb.tostring()
case "Edit"
sb.remove(0,sb.lenght)
sb.append("update committee set ")
sb.append(" memberid = '" & txtmemberid.text & "',")
sb.append(" password = '" & txtpassword.text & "',")
sb.append(" level = '" & txtlevel.text & "'")
sb.append(" where committee_id = '" & txtcommit.text & "'")
strSql = sb.tostring()
end select
com = new sqlcommand(strSql,con)
com.transaction = tr;
com.executenonquery()
tr.commit()
catch (Exception ex)
tr.rollback()
msgbox(ex.tostring)
con.close()
end try
end sub