项目总结| 学生信息管理系统

前言:

        纸上得来终觉浅,觉知此事须躬行。本来以为可以自己做一个学生系统,没想到学生信息系统可以用多种语言来完成,少有用vb语言完成的,多是Java,C 语言的版本,而且复杂的还有什么三层架构,可是我不会呀,所以在自己的幻想中,我浪费了一周的时间,然后又用了一周的时间自己画结构图,自己构想构建一个学生系统需要哪些信息,什么结构,然后一周又过去了,然后不久就迎来了考试准备月,项目什么的,就都放下了,我怕挂科,然后家里不好交代。到了暑假再真正拾起,但是又适逢当值,个人的时间管理做的不是很好,所以每天进步一点点,经过三次的验收优化,我现在对每个控件操作之后,应该需要什么效果有了大致的思路。下面就来谈谈,我的调试和优化之路吧,路虽艰,但收获颇丰。


一。调试(各种错):

1.查询错误

1)

                

解决方法:检查数据库的链接语句是否正确异地发布的时候,因为局域网换了,可能会导致数据库链接不上而报错,


以及通过弹出 txtSQL 和 MsgText 来进行调试。


2)

       

列名在输入的时候,没有以字符的形式进行查询匹配

解决方法:

添加单引号表示字符。


2.数据库导入错误

1)错位:

    

根据数据库中的表和实际的需求进行调整: 

Public Sub viewData() ' 把临时表中当前记录赋给文本框
    
    txtClassno.Text = mrc.Fields(0)
    comboGrade.Text = mrc.Fields(1)
    txtDirector.Text = mrc.Fields(2)
    Comboclass.Text = mrc.Fields(3)
     
End Sub

-----------------------------------------------------------------------------------------------------------------------------------------------------

2)类型不符:


解决方法:打开SQL Server ---》 打开数据库---》展开 student 数据库---》选择右击菜单中的设计查看相应的数据类型,进行代码调试


还有许多就不在这里赘述了,如EOF问题,数据库的连接问题 ... ...

二。第一次优化

第一次验收,自我感觉也不是很好,但是没有想到会爆出这么多错,回炉重造了一下

学生按照功能也无非是添加,修改,查询这三种功能,弄细致就好了。

1)添加了字数提示标签和输错光标返回上一次输入点

(通用)
dim j as integer
dim b(100) as string
-------------------------------------------
Private Sub txtAddress_Change()
Dim i As Integer
j = j + 1

For i = 1 To Len(txtAddress.Text)
     txtAddress.ToolTipText = "还有" & 50 - Len(txtAddress.Text) & "个字可以输入"
     lb_Add.Caption = "还有" & 50 - Len(txtAddress.Text) & "个字可以输入"
     b(j) = txtAddress.Text
     txtAddress.SelStart = (j - 1)
Next i

If Len(txtAddress.Text) > 50 Then
      MsgBox "住址不超过50个字"
     txtAddress.Text = b(j - 1)
     txtAddress.SelStart = (j - 1)
End If
End Sub
2.设置年级课程的防止重复读取年级课程,防止重复设置课程

3.添加成绩信息窗体中,学籍信息,班级信息,考试信息三张表之间的关系

反思:验收时,没有用手机记录下错误,回去,没有完整的调试思路

三。第二次调试

         

四。第三次优化

         

以上就是我的学生总结了,通过这次学生信息管理系统的学习,我对vb程序与数据库之间的关系有了更深的认识,纸上得来总觉浅,觉知此事需躬行。



  • 5
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 90
    评论
package cn.com.dao.chivementdao; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import cn.com.util.DBConnection; import cn.com.util.DBSql; import cn.com.vo.chivementvo.ChivementVo; public class ExamDao { private Connection conn = DBConnection.getConnectionOracle(); private ChivementVo examVo; public ExamDao() { } public ExamDao(ChivementVo examVo) { super(); this.examVo = examVo; } /** * 全部查询 */ public Object[][] selectAll() { Object date[][] = null; int max = 0; int i = 0; PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(DBSql.SELECT_ALL); rs = ps.executeQuery(); // 得到列数 max = rs.getMetaData().getColumnCount(); date = new Object[getnumberAll(DBSql.SELECT_ALL_COUNT)][max]; while (rs.next()) { for (int j = 0; j < max; j++) { date[i][j] = rs.getObject(j + 1); } i++; } // rs.close(); // ps.close(); // conn.close(); } catch (SQLException e) { e.printStackTrace(); } return date; } /** * 根据学号查询 */ public Object[][] selectBySid() { Object date[][] = null; int max = 0; int i = 0; PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(DBSql.SELECT_BY_S_ID); ps.setInt(1, examVo.getS_id()); rs = ps.executeQuery(); // 得到列数 max = rs.getMetaData().getColumnCount(); date = new Object[getnumber(DBSql.SELECT_BY_S_ID_COUNT, examVo .getS_id())][max]; while (rs.next()) { for (int j = 0; j < max; j++) { date[i][j] = rs.getObject(j + 1); } i++; } // rs.close(); // ps.close(); // conn.close(); } catch (SQLException e) { e.printStackTrace(); } return date; } /** * 根据组号查询 */ public Object[][] selectByGid() { Object date[][] = null; int max = 0; int i = 0; PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(DBSql.SELECT_BY_G_ID); ps.setInt(1, examVo.getG_id()); rs = ps.executeQuery(); // 得到列数 max = rs.getMetaData().getColumnCount(); date = new Object[getnumber(DBSql.SELECT_BY_G_ID_COUNT, examVo .getG_id())][max]; while (rs.next()) { for (int j = 0; j < max; j++) { date[i][j] = rs.getObject(j + 1); } i++; } // rs.close(); // ps.close(); // conn.close(); } catch (SQLException e) { e.printStackTrace(); } return date; } /** * 根据课程号查询 */ public Object[][] selectByCid() { Object date[][] = null; int max = 0; int i = 0; PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(DBSql.SELECT_BY_C_ID); ps.setInt(1, examVo.getC_id()); rs = ps.executeQuery(); // 得到列数 max = rs.getMetaData().getColumnCount(); date = new Object[getnumber(DBSql.SELECT_BY_C_ID_COUNT, examVo .getC_id())][max]; while (rs.next()) { for (int j = 0; j < max; j++) { // System.out.println( examVo.getG_id()); date[i][j] = rs.getObject(j+1); } i++; } // rs.close(); // ps.close(); // conn.close(); } catch (SQLException e) { e.printStackTrace(); } return date; } /** * 根据姓名模糊查询 * * @return */ public Object[][] selectByName() { Object date[][] = null; int max = 0; int i = 0; PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(DBSql.SELECT_BY_S_NAME); ps.setString(1, examVo.getS_name()); ps.setString(2, "%" + examVo.getS_name() + "%"); ps.setString(3, "%" + examVo.getS_name()); ps.setString(4, examVo.getS_name() + "%"); rs = ps.executeQuery(); // 得到列数 max = rs.getMetaData().getColumnCount(); date = new Object[getnumberByName(DBSql.SELECT_BY_S_NAME_COUNT, examVo.getS_name())][max]; while (rs.next()) { for (int j = 0; j < max; j++) { date[i][j] = rs.getObject(j + 1); } i++; } } catch (SQLException e) { e.printStackTrace(); } return date; } /** * 根据课程名称模糊查询 * * @return */ public Object[][] selectByClassName() { Object date[][] = null; int max = 0; int i = 0; PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(DBSql.SELECT_BY_CLASS_NAME); ps.setString(1, examVo.getClass_name()); ps.setString(2, "%" + examVo.getClass_name() + "%"); ps.setString(3, "%" + examVo.getClass_name()); ps.setString(4, examVo.getClass_name() + "%"); rs = ps.executeQuery(); // 得到列数 max = rs.getMetaData().getColumnCount(); date = new Object[getnumberByName(DBSql.SELECT_BY_CLASS_COUNT, examVo.getClass_name())][max]; while (rs.next()) { for (int j = 0; j < max; j++) { date[i][j] = rs.getObject(j + 1); } i++; } } catch (SQLException e) { e.printStackTrace(); } return date; } /** * 修改选中学生的成绩 * */ public void updatSelectClass() { PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(DBSql.UPDATE_EXAM_BY_STUID); ps.setInt(1, examVo.getClassExamChivement()); ps.setInt(2, examVo.getS_id()); ps.setInt(3, examVo.getC_id()); ps.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } } /** * 得到所有课程号和课程名 * * @return */ public String[] getClassNoName() { String[] classNoName = null; PreparedStatement ps = null; ResultSet rs = null; int j = 0; try { int i = getnumberAll(DBSql.SELECT_CLASS_NAME_COUNT); classNoName = new String[i + i]; ps = conn.prepareStatement(DBSql.SELECT_CLASS_NAME); rs = ps.executeQuery(); while (rs.next()) { classNoName[j] = rs.getString(1); classNoName[j + i] = rs.getString(2); j++; } } catch (SQLException e) { e.printStackTrace(); } return classNoName; } /** * 根据科目修改成绩 查询学号 姓名 成绩 * */ public void SelectClassStuName() { int i = 0; PreparedStatement ps = null; ResultSet rs = null; int j = getnumberBySelectClassName( DBSql.SELECT_CLASS_STU_SNO_SNAME_EXAM_COUNT, examVo.getC_id()); int[] sNum = new int[j]; String[] sName = new String[j]; int[] classExam = new int[j]; try { ps = conn.prepareStatement(DBSql.SELECT_CLASS_STU_SNO_SNAME_EXAM); ps.setInt(1, examVo.getC_id()); rs = ps.executeQuery(); while (rs.next()) { sNum[i] = rs.getInt(1); sName[i] = rs.getString(2); classExam[i] = rs.getInt(3); i++; } } catch (SQLException e) { e.printStackTrace(); } examVo.setSid(sNum); examVo.setSname(sName); examVo.setClassExam(classExam); } /** * 根据科目修改成绩 查询学号 姓名 成绩 后修改成绩 * */ public void UpdateClassStuName() { // int i = 0; PreparedStatement ps = null; ResultSet rs = null; int j = getnumberBySelectClassName( DBSql.SELECT_CLASS_STU_SNO_SNAME_EXAM_COUNT, examVo.getC_id()); try { ps = conn.prepareStatement(DBSql.UPDATE_CHIVEMENT_BY_CLASS); for(int i =0;i<j;i++){ ps.setInt(1, examVo.getClassExam()[i]); ps.setInt(2, examVo.getSid()[i]); ps.setInt(3, examVo.getC_id()); ps.executeUpdate(); } } catch (SQLException e) { e.printStackTrace(); } } /** * 全部查询获得行数 * * @return */ public int getnumberAll(String str) { int number = 0; PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(str); rs = ps.executeQuery(); rs.next(); number = rs.getInt(1); // rs.close(); // ps.close(); // conn.close(); } catch (SQLException e) { e.printStackTrace(); } return number; } /** * 根据学号 根据组号 根据课程号查询 获得行数 * * @return */ public int getnumber(String str, int i) { int number = 0; PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(str); ps.setInt(1, i); rs = ps.executeQuery(); rs.next(); number = rs.getInt(1); // rs.close(); // ps.close(); // conn.close(); } catch (SQLException e) { e.printStackTrace(); } return number; } /** * 根据姓名 课程名 查询 获得行数 * */ public int getnumberByName(String str, String i) { int number = 0; PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(str); ps.setString(1, i); ps.setString(2, "%" + i + "%"); ps.setString(3, "%" + i); ps.setString(4, i + "%"); rs = ps.executeQuery(); rs.next(); number = rs.getInt(1); } catch (SQLException e) { e.printStackTrace(); } return number; } // /** // * 根据课程名查询 获得行数 // * // */ // // public int getnumberByClassName(String str, String i) { // int number = 0; // PreparedStatement ps = null; // ResultSet rs = null; // try { // ps = conn.prepareStatement(str); // ps.setString(1, i); // ps.setString(2, "%" + i + "%"); // ps.setString(3, "%" + i); // ps.setString(4, i + "%"); // rs = ps.executeQuery(); // rs.next(); // number = rs.getInt(1); // } catch (SQLException e) { // e.printStackTrace(); // } // return number; // } /** * * 根据课程名修改成绩获得行数 * * @param str * @param i * @return */ public int getnumberBySelectClassName(String str, int i) { int number = 0; PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(str); ps.setInt(1, i); rs = ps.executeQuery(); rs.next(); number = rs.getInt(1); } catch (SQLException e) { e.printStackTrace(); } return number; } }

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 90
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值