Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hog,

 

Why don't you put "Me.DataSetAssets1.Clear()" before the "Select Case ctlSender.Name" and see whether it works.

 

- zy_abc

Thanks & Regards,

zy_abc

  • *Experts*
Posted

So your current error is "Select command is not setup"? Set a breakpoint on the line that's causing the error and check the SelectCommand to see what it shows. If it is empty, you'll have to look back (you can use the CallStack) to see what code was called prior to your initialize and see where you think the Select Command was being filled OR where it might be getting cleared.

 

Without seeing your code, it's very difficult to guess what might be clearing out the Select Command.

 

-ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted

Nerseus, I have tried this already. I have put breakpoints everywhere and the code does not stop. However I narrowed it down to the this bit:

 


  Public Sub New()
       MyBase.New()

       'This call is required by the Windows Form Designer.
       InitializeComponent()
       'Add any initialization after the InitializeComponent() call

   End Sub

 

If I put a break point at MyBase.New() that line works. The next line InitializeComponent() gets called and the churns away for a bit then the error is displayed. The error trap I'm using displays it as being in ResetDataset. The selectcommandtext is blank, but further down in the windows designer code is this:

 


  '
       'OleDbSelectCommand1
       '
       Me.OleDbSelectCommand1.CommandText = "SELECT assetid, supplierid, model, type, '[' + type + ']' + ' ' + model + ' ' + s" & _
       "erial AS description FROM tblAsset ORDER BY type"
       Me.OleDbSelectCommand1.Connection = Me.OleDbConnAssets

 

Once I click OK on my error handler form the form opening is displayed and everything works fine.

 

I cannot get the step through code to step into InitializeComponent() so I can see what is happening.

My website
Posted

I feel that the real error is somewhere else. Let's say we have here the proof for a typical MS error message. ;) Just telling that there is an error, but the message does not tell you the real problem.:p

So let's try something else:

There is a little chance that your problem lies within your sql-statement. You use a field name called "type". This should be a reserved word in Access and also SQL Server. So, replace all occurrences of "type" with "[type]" and then try again.

I have yet seen a lot of problems with reserved words in sql-statements, so maybe this explains that irregular behaviour.

Posted

OK thanks for this, however I did not hold out much hope as the selectcommandtext is the same as the other forms. But at this stage I would try sticking my you know what in a jam jar full of angry wasps if I thought it would help.....

 

So I replace all entries of type with [type] to get the same result. The code stops at my breakpoint at InitializeComponent. I F11 the line executes but does not move past the cursor point at InitializeComponent. I get the error again ' selectcommandtext not initialized before call to .fill'. I click OK the everything works ok??

 

I have double checked and the oledataadapter on the form has the selectcommand text set correctly. I have looked in the windows desiger generated code and the entry is there?

 

As the error is happening inside a procedure called InializeComponent that was put there by the IDE I cannot see what code is inside this procedure to see where it is going wrong?

 

My bloody brain is well and trully hurting now!

My website
Posted

:confused: Why can't you see the code inside InitializeComponents?

 

Look out for the line

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

There it starts. Maybe this is a good place to look for the real error. It could be that the order of initializing all your components is wrong for any reason. I had that problem once. This may happen, even if the code is generated automatically. So much for automation. :p

Posted
OK, you have confirmed for me that this is the InializeComponent() procedure, but the cursor stays at the line that calls it. It does not move into the block of code you show above. This is what I meant by not being able to see where exactly it goes wrong :-(
My website
Posted

OK....I HAVE FIXED IT :-)

 

Can anyone explain why this error plagued me until I manually moved all code to do with the dataset, oledbdataadapter and connection into the beginning of the InializeComponent procedure?

 

This means I have modified what the windows designer did to fix the problem? All the other forms work fine with the windows designer placed code, so why would this form be different?

 

Have I as APaule says possibly discovered an MS bug??

My website

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...