学生管理信息系统之实时错误94 无效使用NULL

 

问题一 :实时错误94 无效使用NULL

 

代码如下:

Else
       txtClassno.Text = mrc.Fields(0)
       ComboGrade.Text = mrc.Fields(1)
      txtDirector.Text = mrc.Fields(2)
       txtClassroom.Text = mrc.Fields(3)  
       End If

改写后的代码:

Else
       txtClassno.Text = mrc.Fields(0)
       ComboGrade.Text = mrc.Fields(1)
      txtDirector.Text = mrc.Fields(2)& “”
       txtClassroom.Text = mrc.Fields (3)  & “” 
       End If

解决方法 :

可以在后面加& “”  直接把一个空值的字符串赋值给前面的代码。

问题二:实时错误-2147217885(80040e23)行句柄引用了一个已被删除的行或标识为删除的行

错误之处:
  在点击删除记录时就会报这个错!!
  我在cmdDelete_Click 事件中不合适的位置添加了mrc.Delete语句,导致更新之后原纪录被删除,出现错误
解决办法:
  删除mrc.Delete语句

 

错误三:编译错误: for control 控件变量已经在使用

 

 For selectcourse = 0 To Listallcourse.ListCount - 1
        If Listallcourse.Selected(selectcourse) = True Then
          Listselectcourse.AddItem Listallcourse.List(Listallcourse.ListIndex)
          '向listelectcourse列表中添加课程
           For j = i + 1 To Listselectcourse.ListCount - 1
             For j = i + 1 To Listselectcourse.ListCount
             '判断在list列表中是否有相同名称
        If Listselectcourse.List(i) = Listselectcourse.List(j) Then
           Listselectcourse.RemoveItem j
           MsgBox "以添加此课程!", vbOKOnly + vbExclamation, "提示"
           Exit Sub
         End If
        Next j


报错原因:

循环变量已经在使用的意思···这里的两个循环变量都是 j,而且是镶嵌在一起的,所以会报错 。

解决方法:

将第一个报错的  “  j ”  给为  “i”就可以了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
这里提供一个简单的 Java 学生信息管理系统实现登录注册功能的代码,仅供参考: ```java import java.util.Scanner; public class Main { public static void main(String[] args) { StudentManagementSystem system = new StudentManagementSystem(); Scanner scanner = new Scanner(System.in); while (true) { System.out.println("欢迎使用学生信息管理系统"); System.out.println("1. 注册"); System.out.println("2. 登录"); System.out.println("3. 退出"); System.out.print("请选择操作:"); int choice = scanner.nextInt(); scanner.nextLine(); switch (choice) { case 1: System.out.print("请输入用户名:"); String username = scanner.nextLine(); System.out.print("请输入密码:"); String password = scanner.nextLine(); System.out.print("请输入姓名:"); String name = scanner.nextLine(); System.out.print("请输入年龄:"); int age = scanner.nextInt(); scanner.nextLine(); system.register(username, password, name, age); break; case 2: System.out.print("请输入用户名:"); String loginUsername = scanner.nextLine(); System.out.print("请输入密码:"); String loginPassword = scanner.nextLine(); if (system.login(loginUsername, loginPassword)) { while (true) { System.out.println("1. 添加学生信息"); System.out.println("2. 修改学生信息"); System.out.println("3. 删除学生信息"); System.out.println("4. 查询学生信息"); System.out.println("5. 返回上一级"); System.out.print("请选择操作:"); int subChoice = scanner.nextInt(); scanner.nextLine(); switch (subChoice) { case 1: System.out.print("请输入学生姓名:"); String studentName = scanner.nextLine(); System.out.print("请输入学生年龄:"); int studentAge = scanner.nextInt(); scanner.nextLine(); system.addStudent(studentName, studentAge); break; case 2: System.out.print("请输入要修改的学生ID:"); int modifyId = scanner.nextInt(); scanner.nextLine(); System.out.print("请输入新的学生姓名:"); String newStudentName = scanner.nextLine(); System.out.print("请输入新的学生年龄:"); int newStudentAge = scanner.nextInt(); scanner.nextLine(); system.modifyStudent(modifyId, newStudentName, newStudentAge); break; case 3: System.out.print("请输入要删除的学生ID:"); int deleteId = scanner.nextInt(); scanner.nextLine(); system.deleteStudent(deleteId); break; case 4: system.queryAllStudents(); break; case 5: break; default: System.out.println("无效的操作,请重新选择!"); break; } if (subChoice == 5) { break; } } } else { System.out.println("用户名或密码错误!"); } break; case 3: System.out.println("谢谢使用!"); System.exit(0); break; default: System.out.println("无效的操作,请重新选择!"); break; } } } } class Student { private int id; private String name; private int age; public Student(int id, String name, int age) { this.id = id; this.name = name; this.age = age; } public int getId() { return id; } public String getName() { return name; } public int getAge() { return age; } public void setName(String name) { this.name = name; } public void setAge(int age) { this.age = age; } @Override public String toString() { return "学生ID:" + id + ",姓名:" + name + ",年龄:" + age; } } class StudentManagementSystem { private Student[] students = new Student[100]; private int count = 0; private int id = 1; public void register(String username, String password, String name, int age) { System.out.println("注册成功!"); } public boolean login(String username, String password) { if ("admin".equals(username) && "123456".equals(password)) { System.out.println("登录成功!"); return true; } return false; } public void addStudent(String name, int age) { students[count++] = new Student(id++, name, age); System.out.println("添加成功!"); } public void modifyStudent(int id, String name, int age) { for (int i = 0; i < count; i++) { if (students[i].getId() == id) { students[i].setName(name); students[i].setAge(age); System.out.println("修改成功!"); return; } } System.out.println("未找到指定的学生ID!"); } public void deleteStudent(int id) { for (int i = 0; i < count; i++) { if (students[i].getId() == id) { for (int j = i; j < count - 1; j++) { students[j] = students[j + 1]; } students[--count] = null; System.out.println("删除成功!"); return; } } System.out.println("未找到指定的学生ID!"); } public void queryAllStudents() { if (count == 0) { System.out.println("暂无学生信息!"); return; } for (int i = 0; i < count; i++) { System.out.println(students[i]); } } } ``` 这个学生信息管理系统中,主要实现了以下功能: - 注册 - 登录 - 添加学生信息 - 修改学生信息 - 删除学生信息 - 查询学生信息 其中,注册和登录功能只是简单的输出提示信息,没有实现真正的注册和登录逻辑。在实际项目中,需要根据具体需求进行实现。 如果需要将这个学生信息管理系统保存到文件中,可以使用 Java 的文件操作功能,将学生信息保存到文件中,再从文件中读取学生信息。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值