Solved

Data Grid control returning error constants!

Posted on 2000-03-27
26
423 Views
Last Modified: 2008-03-10
I'm using a data grid control to display elements from a database.

My requirement needs that i populate different data from different tables in the database depending on the menu items i select.

the problem I'm facing is that when i chose a menu item, the records get populated in the data grid control correctly.

if i select a field in the data grid and then chose another menu item that causes the contents of the data grid control to change, i get a message box saying : "The current row is not available"
After i click on "OK", i get the next set of reports correctly listed in the control.

Basically the data is getting populated correctly, the only thing bothering us is the message box each time the data needs to be changed.

Is there a way we could eliminate this message box from appearing?

These are a few findings:
we looked up the MSDN library and found that this message is displayed when the following error constant is returned : dbgNoCurrentRow

The value returned by this is 7008.

however we are unable to find out the reson why this is being logged and how we can avoid this.

Kindly enlighten us.

Thanks,
0
Comment
Question by:vidyas
  • 14
  • 4
  • 4
  • +2
26 Comments
 

Expert Comment

by:jdhananjay
ID: 2662795
hi
 try this
 What u do First time when u assign the datasource to datagrid then it is not giving error Ok. When u select other item from menu and then u assignging the that time do this
set datagrid1.datasource = nothing
datagrid1.clearfields
And then assign ur new recordset to Datagrid.
Good Luch
Bye
Jay
0
 

Expert Comment

by:pinshah
ID: 2662936
Open the datasource as readonly.
0
 
LVL 14

Expert Comment

by:wsh2
ID: 2662996
Set Datagrid1.Allowupdate = False.. when in Inquiry mode. Set it back to True if/when you need to update.. <smile>.
0
 

Author Comment

by:vidyas
ID: 2663025
checked setting datagrid.datasource to nothing and checked using datagrid1.clearfields.

The message box still turns up, while a field is selected, but does not turn up when no fields are selected.

datasource is opened as "Read_only"

(Thanks for your suggestions)
Any more?
0
 

Expert Comment

by:AshokKumar
ID: 2663051
Just give On Error Resume Next as the first statement of the procedure and contnue. U would not get any problems.
0
 

Expert Comment

by:pinshah
ID: 2663098
Are u writing any event when the data or cell changes in the DataGrid.

0
 

Author Comment

by:vidyas
ID: 2663132
Adjusted points from 50 to 65
0
 

Author Comment

by:vidyas
ID: 2663133
Cannot try "On Error Resume Next" as i am handling other errors in the same procedure.

Nope, i'm not writing any event when the data changes in the Data Grid.
0
 

Expert Comment

by:pinshah
ID: 2663154
Send the code
0
 

Author Comment

by:vidyas
ID: 2663355
- Here's the code snippet -

 Set DataGrid1.DataSource = Nothing
 DataGrid1.ClearSelCols
 DataGrid1.ClearFields

 conRpt.Open "DSN=tracer"
 conRpt.CursorLocation = adUseClient

 cmd.ActiveConnection = conRpt
 cmd.CommandText = TracerInit.strRptQryName
 cmd.CommandType = adCmdStoredProc

 For i = 1 To TracerInit.nRptParamNum
     Set prm = cmd.CreateParameter(TracerInit.strRptParam(i), adInteger, adParamInput)
    cmd.Parameters.Append prm
    prm.Value = TracerInit.valRptParam(i)
 Next
 Set rsRpt = cmd.Execute
 cmd.cancel
 Set Me.Adodc1.Recordset = rsRpt
 
 Set DataGrid1.DataSource = Adodc1

 '--display block
 '//-To adjust the grid column widths according to the text size
 ReDim lenArray(Me.DataGrid1.Columns.Count)
 '//-LenArray contains the max width of each column
 For Each colItem In Me.DataGrid1.Columns
    lenArray(colItem.ColIndex) = Len(rsRpt.Fields(colItem.ColIndex).Name)
    rsRpt.MoveFirst
    While Not rsRpt.EOF
        ncolLength = Len(CStr(Format(rsRpt(colItem.ColIndex).Value)))
        If lenArray(colItem.ColIndex) < ncolLength Then
            lenArray(colItem.ColIndex) = ncolLength
        End If
        rsRpt.MoveNext
    Wend
    lenArray(colItem.ColIndex) = lenArray(colItem.ColIndex) * 110
    colItem.Width = lenArray(colItem.ColIndex)
    ntotlength = ntotlength + (lenArray(colItem.ColIndex))
 Next
 
0
 

Expert Comment

by:jdhananjay
ID: 2663611
hi

Set Me.Adodc1.Recordset = rsRpt  
Set DataGrid1.DataSource = Adodc1

use this

Set DataGrid1.DataSource = rsRpt  

And Use

do until rsRpt.EOF = True
ncolLength = Len(CStr(Format(rsRpt
          (colItem.ColIndex).Value)))
If lenArray(colItem.ColIndex) <  
                    ncolLength Then
 lenArray(colItem.ColIndex)= ncolLength
End If
   rsRpt.MoveNext
loop

insted of
While Not rsRpt.EOF
  ncolLength = Len(CStr(Format        
    (rsRpt(colItem.ColIndex).Value)))
 If lenArray(colItem.ColIndex) <
                     ncolLength Then
 lenArray(colItem.ColIndex)= ncolLength
 End If
     rsRpt.MoveNext
Wend
0
 

Author Comment

by:vidyas
ID: 2668445
Edited text of question.
0
 

Author Comment

by:vidyas
ID: 2668449
Edited text of question.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:vidyas
ID: 2671773
Tried using do until instead of while!

Does not work.
0
 

Author Comment

by:vidyas
ID: 2699805
Any other answers as yet?
0
 
LVL 14

Expert Comment

by:wsh2
ID: 2700938
First of all, delete these lines:

Set DataGrid1.DataSource = Nothing
DataGrid1.ClearSelCols
DataGrid1.ClearFields

and down further:

Set DataGrid1.DataSource = Adodc1
 
As the Datagrid is going to get overlayed they are unnecessary.

--------------------------------------
You now have two choices:

1.  If you want to update the ADODC, then change this line to read:

Set Me.Adodc1.Recordset = rsRpt
Me.Adodc1.Refresh

2.  To be honest, you don't need the Adodc1 to accomplish what you want. Change:

Set Me.Adodc1.Recordset = rsRpt

To:

Set DataGrid1.DataSource = rsRpt

and the Datagrid will be updated accordingly.


 
0
 

Author Comment

by:vidyas
ID: 2702802
hi wsh2, it still gives the same error.
maybe i need to change the control itself.
0
 
LVL 14

Expert Comment

by:wsh2
ID: 2702911
No.. I think the control is fine.. <smile>. What I'm now thinking is that you have an unfinished transaction somewhere.. an .addnew or an .edit or a .delete that you have not followed up with an .update. This would cause a record page lock.. and a record unavailable message. Can you check your logic for this? Or.. perhaps somewhere else in your program.. you are accessing a part of the same table where a record page lock is taking place. Mind you, that is only an educated guess.. but I certainly would check that out.

You may also want to check out your CursorTypes. Only a setting of adUseStatic is supported if the CursorLocation property is set to adUseClient. If a provider does not support the requested cursor type, the provider may return another cursor type. Perhaps the quickest way to remedy this would be to change your CursorLocation to adUseServer. By the way, what ODBC provider are you using?

Welp.. give that adUseServer thing a shot.. and see how it works out.. meanwhile, I will (along with the others) give it more thought.. <smile>.
0
 

Author Comment

by:vidyas
ID: 2703189
Adjusted points from 65 to 90
0
 

Author Comment

by:vidyas
ID: 2703220
Nope, i checked out for unfinished transactions. since i'm doing all updations, additions, deletions through a connection object, i don't think an 'update' is needed - a "con.execute" should suffice.

n reg the adUseServer thing, i tried changing the cursorLocation to adUseServer.. it still gives the error!!

ODBC Driver being used is MS Access,
Thanks.
0
 

Author Comment

by:vidyas
ID: 2729379
Folks, now the problem seems to have changed, might give us further insight to the problem.

I changed the database options to open it in "Exclusive Mode" only.

and now the earlier error: "current row not available" has been replaced with this one: "[Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed "

However the message box pops up at the same instances as the previous one, that is, if a field of the grid is selected.

Findings::
Found that this error gets logged possibly by SQLBrowseConnect ,SQLConnect or  SQLDriverConnect

Problem again: I'm *not* using any of the above statements.

I'm only using a connection object to connect to the databse. is this creating problems?

Any clues now to remove this message box?
0
 

Accepted Solution

by:
jdhananjay earned 90 total points
ID: 2729568
hi
  U are just browsing that means not adding,changing,deleting.If u r browsing only then do one thing
After binding the recordset to grid.
Set rs.Activeconnection = Nothing.

Good Luck.
Jay

 
0
 

Author Comment

by:vidyas
ID: 2729605
Would like to give some points to others too, is that possible?

0
 
LVL 14

Expert Comment

by:wsh2
ID: 2729700
To leave additional points.. just post a question with "FOR <screenname> ONLY" in the question subject.. and assign it the points you feel deserved.
0
 

Expert Comment

by:jdhananjay
ID: 2730067
Hi Vidyas
  Thanks for accepting my answer.
If u have any problem contact me on hijai23@yahoo.com.
Good Luck.
Bye
Jay
0
 

Author Comment

by:vidyas
ID: 2730121
Thanks a bunch to all those involved!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now