Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > BOOK: Beginning VB.NET Databases
|
BOOK: Beginning VB.NET Databases
This is the forum to discuss the Wrox book Beginning VB.NET Databases by Thearon Willis; ISBN: 9780764568008
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning VB.NET Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 10th, 2005, 02:23 PM
Registered User
 
Join Date: Jul 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Object Variable or With Block Variable not Set

I am on Chapter 7: Implementing Group Queries. I completed steps 1-8 (pages 162-167. However, when I run the app I get the following message: Object Variable or With Block Variable not Set. I ran the same code from the download and I did not get the error. I compared the two sets of code and could not see a difference. I know that the error occurs after running DALBase FillDataSet procedure. It runs the InitializeCommand, InitializeDataAdapter, DataAdapter.Fill(oDataSet, TableName)then the Finally section: command.dispose, command = nothing, dataadapter.dispose and dataadapter = nothing. Then the system goes right to the Exception Error in the LoadGroups procedure. What am I doing wrong?
 
Old July 11th, 2005, 05:05 AM
Thearon's Avatar
Wrox Author
 
Join Date: Dec 2003
Posts: 396
Thanks: 0
Thanked 8 Times in 8 Posts
Default

I can't think of anything right off hand that might be causing the problem. Set a breakpoint on the line of code that fills the dataset and when it returns query the dataset to ensure that it has rows of data in it.

Thearon
 
Old July 11th, 2005, 11:01 AM
Registered User
 
Join Date: Jul 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I did as you suggested. I set up a Watch window on DataAdapter.Fill(oData,TableName). The result it returned was 1 (which was good as I had one record in the table). Then when I went to the next command Command.Dispose(), the value on the DataAdapter.Fill changed to:Run-time exception thrown : System.InvalidOperationException
 - Fill: SelectCommand.Connection property has not been initialized.
Now what do I do?
 
Old July 12th, 2005, 04:23 AM
Thearon's Avatar
Wrox Author
 
Join Date: Dec 2003
Posts: 396
Thanks: 0
Thanked 8 Times in 8 Posts
Default

What you're saying isn't making much sense to me. However, set a break point on the first line of code in the OpenConnection procedure in the DALBase class to ensure that code is getting executed.

The other suggestion that I have for you is to use some tool to compare the DALBase class from your project to the one you downloaded to see if you can find the differences between them.

Thearon
 
Old July 12th, 2005, 01:02 PM
Registered User
 
Join Date: Jul 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok, I stepped through the code starting at LoadGroups(). I noticed that when I ran the book code the connection opened during the Sub New procedure, once the variable "connection" was set. When I run my code the connection doesn't open during Sub New. When I look at the details of the variable connection in the watch window, the only property difference was the ServerVersion. Yours has an entry for 4.something and my had an entry of
[u]ServerVersion <error: an exception of type: {System.InvalidOperationException} occurred> String</u>
... and the connection never opens. I am going to call the procedure OpenConnection and see what happens. What think ye?
 
Old July 13th, 2005, 04:03 AM
Thearon's Avatar
Wrox Author
 
Join Date: Dec 2003
Posts: 396
Thanks: 0
Thanked 8 Times in 8 Posts
Default

Are you connecting to SQL Server or Oracle? Post you connection string here (with xxx as the password) so I can have a look at it.

Thearon





Similar Threads
Thread Thread Starter Forum Replies Last Post
Object variable or With block variable not set haidee_mccaffrey Classic ASP Professional 5 March 8th, 2007 03:34 PM
"object variable or with block variable not set" netfresher ASP.NET 1.0 and 1.1 Basics 1 June 12th, 2006 03:50 PM
object variable or with block variable not set Aoude BOOK: Beginning VB.NET Databases 1 February 24th, 2006 05:21 PM
Object variable or With block variable not set tparrish VB Databases Basics 1 May 25th, 2005 10:25 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.