SQL Server Live Error: Object variable or with block variable not set

Source: Internet
Author: User
Tags execution odbc

People these days in doing student information management system, appear

The most should be the problem, "Real time error ' 91 ': Object variable or with block variable not set." As shown on the right:

In this case, we should first refer to MSDN, but at this point MSDN does not seem to help us a lot, summed up, in fact, there are many kinds of errors in the situation:

1. No ODBC data source or ODBC data source configuration error was configured prior to running the program, assuming that SQL Server executed the associated SQL code (the Student.mdb file used in the student system).

2, code problems, most of the cases are query statements have problems, such as:

(1), less space between SQL statements: txtsql = "SELECT * Fromstudent_info"

More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/database/SQLServer/

(2) In the form where the student status information is executed, the execution statement txtsql = "SELECT * from Result_info where", because the condition is added later, so there is an error in missing space between ' where ' and ' '.

(3) In a complete query, such as txtSQL = "SELECT * from Class_info where class_no= '" & Trim (Txtclassno.text) & "", where in the Final Judgment input box conditions, double quotes and single quotes must be noted (the whole quote is divided into three layers from outside to inside: double quotes, single quotes, double quotes), not to break their order level, nor absent-minded.

3, logic error: The lack of statements, the execution of the sentence txtSQL correct assignment, directly manipulate the data in the database, saying that the popular point is not yet connected to the database on the operation, which is also my mistake. After assigning the value directly executes to the database additions and deletions to check, completely puts the call judgment and the connection database function ExecuteSQL behind the brain.

4, there is the MSDN prompts, such as the attempt to use the object variable has been set to nothing and so on, there is no more to say, please refer to the MSDN for VB6.0

Related Article

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.