The student information management system according to the code. After the code is completed, the system is full of loopholes. The prompt box below was first met.
When this prompt appears, click the debug button to return
<span style="font-size:18px;">If mrc.EOF = True Then</span>
The quickest way to troubleshoot problems in VB is to go to msdn for VB to find relevant information. When installing msdn, click Help.
The figure shows that the error type is the object variable or the with block variable, but there is no with Block Variable here, so there is only one situation, the object variable is not set. Only one recordset record set defined in MRC is used here. The cause is that the recordset record set is not connected to the database, and the EOF and BOF attributes of the recordset object are invalid.
There are many reasons for not connecting to the database, the most common of which is the following three.
- ODBC Data Source Not Configured
- An error occurred while connecting the module to the database.
- Whether the SQL statement is wrong.
- The most common problem with ODBC data source configuration is that there is no local server, so we can enter an English point on the server to connect.
<Span style = "font-size: 18px;"> 'mark as a file DSN, access the ODBC data source </span> <PRE name = "code" class = "VB"> <span style = "font-size: 18px;"> Public Function connectstring () as string 'is used to connect to the database </span> <PRE name = "code" class = "VB"> <span style = "font-size: 18px; "> <span style =" white-space: pre "> </span> connectstring =" filedsn = student. DSN; uid = sa; Pwd = fxq "</span>
<span style="font-size:18px;">End Function</span>
The student after filedsn must be the name of the DSN File when ODBC is configured. UID is the account used to log on to SQL Server, and PWD is the password used to log on to SQL Server. It must be consistent with that on your computer.
<Span style = "font-size: 18px;"> txtsql = "select * From course_info where course_no = '" & trim (txtcourseno. text) & "'"' SQL statement </span>
The structure of the SQL statement, from the outer to the inner, is double quotation marks, single quotation marks, double quotation marks, and & connector. The meaning of this statement is: select the course number from the course_info table, so that it is equal to the content of the txtcourseno input box, you must write on the basis of understanding this statement, in this way, we can avoid many low-level errors that are least noticeable due to carelessness and ignorance of the Code.
For the first time, I have never touched on some of the database system code. In this case, the letters and punctuation marks are the most likely errors. During the error correction process, it will take us a lot of time. A lot of code in the student information management system is repeated. When coding, you must understand the code at the beginning, so that you can learn more easily and reduce the occurrence of errors.