Steps to Reproduce Behavior
In 32-bit ODBC Administrator, create a new File DSN based on the Access ODBC driver. For the database, select the NWind.mdb file that is in the Visual Basic program folder. Name the new File DSN NWind.
In Visual Basic, create a new Standard EXE Project. Form1 is created by default.
1 Select the Project menu, and choose Remove Form1.
2 Select Project, References and add a reference to the Microsoft DAO 3.51 Object Library.
3 Select Project, Add Module to add a new code module. In the new module's code window, add the following code: Sub main() Dim ws as DAO.Workspace
Dim db as DAO.Database
Set ws = CreateWorkspace("ws", "admin", "", dbUseJet)
Set db = ws.OpenDatabase("", , False, "odbc;") End Sub
4 Save the module as TestHang.BAS and the project as TestHang.VBP.
Test the project:
Press F5 to run the code.
From the Select Data Source dialog box, select the NWind.dsn
File Data Source.
Visual Basic will hang.
Press CTRL+ALT+DEL to end the TestHang application and Visual Basic.
Restart Visual Basic.
Open the TestHang project.
In the code module, change the workspace from dbUseJet to dbUseODBC:
Set ws = CreateWorkspace("ws", "admin", "", dbUseODBC)
Press the F5 key to run the code.
From the Select Data Source dialog box, select the NWind.dsn
File Data Source.
Visual Basic will not hang.
In 32-bit ODBC Administrator, create a new File DSN based on the Access ODBC driver. For the database, select the NWind.mdb file that is in the Visual Basic program folder. Name the new File DSN NWind.
In Visual Basic, create a new Standard EXE Project. Form1 is created by default.
1 Select the Project menu, and choose Remove Form1.
2 Select Project, References and add a reference to the Microsoft DAO 3.51 Object Library.
3 Select Project, Add Module to add a new code module. In the new module's code window, add the following code: Sub main() Dim ws as DAO.Workspace
Dim db as DAO.Database
Set ws = CreateWorkspace("ws", "admin", "", dbUseJet)
Set db = ws.OpenDatabase("", , False, "odbc;") End Sub
4 Save the module as TestHang.BAS and the project as TestHang.VBP.
Test the project:
Press F5 to run the code.
From the Select Data Source dialog box, select the NWind.dsn
File Data Source.
Visual Basic will hang.
Press CTRL+ALT+DEL to end the TestHang application and Visual Basic.
Restart Visual Basic.
Open the TestHang project.
In the code module, change the workspace from dbUseJet to dbUseODBC:
Set ws = CreateWorkspace("ws", "admin", "", dbUseODBC)
Press the F5 key to run the code.
From the Select Data Source dialog box, select the NWind.dsn
File Data Source.
Visual Basic will not hang.
解决方案 »
- DLL调用,实时错误“49”:DLL调用约定错误
- A表中多字段与B表中同一字段相关联,如果设计为好?
- 求救,VC函数转为VB参数的对应转化问题
- 打开串口文件API函数CreateFile,高手请进,急!!!
- 利用vb开发的控件,如何在控件中点击按钮的时候打开一个新的ie页面?
- 紧急求助!!!
- 找不到工程或库---答对马上结
- ^^^^^关于对表查询的语句^^^^^
- 50分请大家看看http://www.csdn.net/Expert/TopicView1.asp?id=910123,给点意见!
- 怎样使用下载的控件?
- 在VB中如何读取数据库中的图片到picturebox控件中
- 简单问题:如何向数据库中添加数据?(VB,DAO)
实在不行就用rdo