Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error: -2147217908 message

Status
Not open for further replies.

seema165

Programmer
Jul 11, 2005
48
GB
Hi,

I keep getting an error saying-

Error: -2147217908
Description: Command text was not set for the command object.

Does anyone know what this means? I have 2 combo boxes and each time I clear the selected values and I refresh the datagrid I have, it brings up this message.

Thanks in advance
 
At first glance (and without seeing any code) it looks like you are missing some SQL and there is no query being run against the database when refreshing the grid.

HTH

TazUk

[pc] Blue-screening PCs since 1998
 
Hi Tazuk,

I have a query running against the database as it does clear the 2 comboboxes after I say ok to the error message. But the problem is that it doesn't refresh the datagrid - hence why I think I am getting the error message.
Here's the SQL for the refresh

strSelectSQL = "SELECT ActivityResponsibleID, isnull(Code.GlobalCodeId,'') AS 'ResponsibleCODE',"
strSelectSQL = strSelectSQL & " isnull(CaesarUser.Surname, '') + ', ' + isnull(CaesarUser.FirstName, '-') AS 'CaesarUserID',"
strSelectSQL = strSelectSQL & " cast(ActivityResponsible.CreateDate-2 as datetime) AS 'CreateDATE', isnull(CreateUser.Surname, '') + ', ' + isnull(CreateUser.FirstName, '-') AS 'CreatedBy'"
strSelectSQL = strSelectSQL & " From ActivityResponsible"
strSelectSQL = strSelectSQL & " INNER JOIN Code ON ActivityResponsible.ResponsibleCODE = Code.CodeID"
strSelectSQL = strSelectSQL & " INNER JOIN CaesarUser ON ActivityResponsible.CaesarUserID = CaesarUser.CaesarUserID"
strSelectSQL = strSelectSQL & " INNER JOIN CaesarUser CreateUser ON ActivityResponsible.CreatedBy = CreateUser.CaesarUserID"
strSelectSQL = strSelectSQL & " WHERE ResponsibleCODE = " & guidActivityResponsibleID
strSelectSQL = strSelectSQL & " OR ActivityResponsible.CaesarUserID = " & guidActivityResponsibleID
strSelectSQL = strSelectSQL & " ORDER BY [ActivityResponsible].[ResponsibleCODE] "

Any help would be good
 
Is the datagrid bound using an ADO Data control, or are you using it in conjunction with a recordset?

Have you tried pausing the code within the refresh and checking that all necessary elements (connection string, database name, etc) are in place and populated correctly?



TazUk

[pc] Blue-screening PCs since 1998
 
If it still doesn't work, send the code that you use to set something equal to your strSelectSQL string. The problem doesn't look like it's inside your string.

Bob
 
Hi BobRodes,

After the above strSelectSQL code I have the following code:

Set objActivityResponsibleRS = m_objCaeScript.CreateADORecordset(strSelectSQL)

Set ActivityResponsibleSelectGrid.DataSource = objActivityResponsibleRS

It still doesn't work and I still get this error.

Any help would be appreciated.
 
Are you able to pause the code before setting the grid datasource and view the contents of objActivityResponsibleRS in the immediate window?

TazUk

[pc] Blue-screening PCs since 1998
 
Set a breakpoint on line
Code:
Set ActivityResponsibleSelectGrid.DataSource = objActivityResponsibleRS

Check state of recordset (using immediate window):
Code:
?objActivityResponsibleRS.state = adstateopen

Check source of recordset (using immediate window) - should return your SQL:
Code:
?objActivityResponsibleRS.Source

Check contents of recordset (using immediate window):
Code:
?objActivityResponsibleRS.Fields("ActivityResponsibleID").Value

If these checks fail I'd suggest looking again at the code in procedure m_objCaeScript.CreateADORecordset

HTH

TazUk

[pc] Blue-screening PCs since 1998
 
Tazuk,

how do I set a breakpoint on that line.

You have to forgive me for asking every detail, but I have only studied VB 6 for 3 months and that was about 3 years ago and this is the first real piece of work I am doing since then.

I have added the rest of the print codes you gave me but they don't give me any output, so I don't think there's anything wrong with that.

Still need help with this.
 
Breakpoints are set using F9 when on the relevant line of code, or the appropriate icon on the debug toolbar.

The code lines I gave above were for use when paused in code, to be entered in the immediate line - not to be added to the code itself.

TazUk

[pc] Blue-screening PCs since 1998
 
I tried that, but it doesn't work, the code doesn't actually pause.

I'm not sure what's wrong with this.

I guess I'll just have to try and trace where abouts its falling over.

Thanks for your help everyone though.

C
 
If you are setting the breakpoint correctly the code will pause.
A breakpoint is indicated with a red dot on the margin against the line of code set as breakpoint. If you see a blue square in the margin, you have set a bookmark rather than a breakpoint.

HTH

TazUk

[pc] Blue-screening PCs since 1998
 
I have set the breakpoint, but its not pausing anywhere and I keep getting the same error still

C
 
Then logically the code must be erroring out before the breakpoint.
All I can suggest is using a combination of breakpoints and stepping through the code line by line (using F8) to locate the problem line / section of code. Once you have that we will be able to assist further.

TazUk

[pc] Blue-screening PCs since 1998
 
You can start with a breakpoint on your first line of code. Press f8 to step through lines 1 at a time.

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top