Real-time error '91 ': the object variable or with block variable is not set

Source: Internet
Author: User

This problem occurs most when you are working on the student information management system over the past few days. "Real-time error '91 ': the object variable or with block variable is not set ". As shown in the right figure:

 

 

When we encounter this problem, we should first refer to msdn, but at this time, msdn does not seem to help us a lot. To sum up, there are actually many situations of this error:

 

 

1. Before running the program, the ODBC data source or ODBC data source configuration error is not configured. Of course, the premise is that SQL Server executes the relevant SQL code (student. MDB file used in the student system ).

 

 

2. Code problems. In most cases, the query statement is faulty, for example:

(1) There is no space between SQL statements: txtsql = "select * fromstudent_info"

(2) In the form that executes the query of student status information, execute the statement txtsql = "select * From result_info where". Because conditions need to be added later'
.

 

(3) In a complete query statement, for example, txtsql = "select * From class_info where class_no = '" & trim (txtclassno. text) & "'", when determining the conditions in the input box at last, double quotation marks and single quotation marks must be noted (the quotation marks of the entire sentence are divided into three layers from the outside to the inside: Double quotation marks, single quotation marks, double quotation marks (double quotation marks.

 

 

3. Logic error: the statement is missing. After correctly assigning values to the execution statement txtsql, you can directly operate on the data in the database. In other words, you can operate on the execution statement without connecting to the database, this is also my mistake. After assigning values, you can directly add, delete, modify, and query the database, leaving the executesql function for calling and determining and connecting to the database completely behind.

 

 

4. There are also prompts in msdn. For example, the object variable you are trying to use has been set to nothing. I will not talk about it more here. For details, refer to msdn for VB6.0.

 

 

 

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.