[Student information management system] The object variable or with block variable is not set

Source: Internet
Author: User
Tags dsn

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.

  1. ODBC Data Source Not Configured
  2. An error occurred while connecting the module to the database.
  3. Whether the SQL statement is wrong.

  1. 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.
  2. <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.
  3. <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.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.