Visual Basic, .NET, ASP, VBScript
 

   
   
     

Форум - Работа с данными

Страница: 1 |

 

  Вопрос: Run-time error '7004' Добавлено: 08.10.03 16:50  

Автор вопроса:  ivan_81 | ICQ: 346805121 

Подскожите пожалуйста что за ошибка такая:

Run-time error '7004'

The rowset is not bookmarkable

Привожу код:

В модуль класса:

_____________________________________________________________________

Private mrsCustomer As ADODB.Recordset

Private Sub Class_Initialize()

Set mrsCustomer = New ADODB.Recordset

mrsCustomer.Source = "select * from tblCustomer"

mrsCustomer.CursorType = adOpenKeyset

mrsCustomer.LockType = adLockOptimistic

mrsCustomer.ActiveConnection = "DSN=JetNovelty;"

mrsCustomer.Open

DataMembers.Add "Customers"

End Sub

Private Sub Class_GetDataMember(DataMember As String, Data As Object)

Select Case DataMember

Case ""

Set Data = Nothing

Case "Customers"

Set Data = mrsCustomer

Case Else

' Raise an error here

End Select

End Sub

_____________________________________________________________________

В frmMain :

_____________________________________________________________________

Private mCustData As CCustData

Private Sub Form_Load()

' Create the data source object

Set mCustData = New CCustData

' Bind the object to grid

Set DataGrid1.DataSource = mCustData

DataGrid1.DataMember = "Customers" '<---------Здесь вылетает ошибка

End Sub

_____________________________________________________________________

На форме DataGrid.

Где ошибка?

Может кто подскажет.

Пардон, ошибка вылетает на END SUB завершающем Sub Class_GetDataMember

После прохода DataGrid1.DataMember = "Customers"

Ответить

  Ответы Всего ответов: 2  

Номер ответа: 1
Автор ответа:
 Last_Santa



ICQ: 200700724 

Вопросов: 38
Ответов: 329
 Web-сайт: localhost
 Профиль | | #1
Добавлено: 22.10.03 05:54

Knowledge Base

PRB: Cannot Bind OLEDB DataGrid Control to Recordset That Does Not Support Bookmarks

PSS ID Number: Q278408

Article Last Modified on 01-11-2001


The information in this article applies to:

  • Microsoft Visual Basic Professional Edition for Windows 6.0
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0
  • ActiveX Data Objects (ADO) 2.0, 2.1, 2.1 SP1, 2.1 SP2, 2.5, 2.6


 

Symptoms

When you attempt to bind an OLEDB DataGrid control to a forward-only or dynamic ActiveX Data Objects (ADO) recordset, you may receive the following run-time error message:

Run-time error '7004': The Rowset is not bookmarkable


 

Cause

You cannot bind the DataGrid control to recordsets that do not support bookmarks. The forward-only and dynamic ADO recordsets do not support bookmarks, and therefore cannot be specified as the DataSource for an OLEDB DataGrid control.


 

Resolution

Bind the DataGrid to a bookmarkable recordset such as the keyset and static ADO recordsets.


 

More Information

Steps to Reproduce Behavior

  1. In Visual Basic version 6.0, create a new Data project.

  2. In the frmDataEnv form, add a DataGrid and a CommandButton control.

  3. In the frmDataEnv form module, paste the following code:

    NOTE: Supply the required connection parameters to the cn.Open statement to connect to the SQL Server, and specify a valid table name in the rs.Open statement.
    'General Declarations SectionDim cn As ADODB.ConnectionDim rs As ADODB.RecordsetPrivate Sub Command1_Click()Set cn = New ADODB.ConnectionSet rs = New ADODB.Recordsetcn.Open "Provider=SQLOLEDB;Data Source=<<I>SQL Server</I>>;Initial Catalog=<<I>SQL Database</I>>;User Id=<<I>SQL UserId</I>>;Password=<<I>SQL Password</I>>"rs.Open "Select * from <<I>TableName</I>>", cn, adOpenDynamic, adLockOptimisticSet DataGrid1.DataSource = rsEnd Sub 
  4. Save and then run the project.

  5. When frmDataEnv is displayed, click the command button.

    You receive the error specified in the "Symptoms" section of this article.

  6. Modify the rs.Open statement in the Command1_Click() event procedure to open a keyset or a static ADO recordset. To do this, replace the constant adOpenDynamic with adOpenKeyset or adOpenStatic.

  7. Save and then run the project.

  8. On frmDataEnv, click the command button.

    The records in the specified table in the OLEDB DataGrid control are displayed.

Additional query words: 7004

Keywords: kbADO kbVBp600 kbDSupport
Issue Type: kbprb
Technology: kbVBSearch kbAudDeveloper kbADOsearch kbADO210 kbADO200 kbADO210sp1 kbADO210sp2 kbADO250 kbADO260 kbZNotKeyword6 kbZNotKeyword2 kbVB600Search kbVBA600 kbVB600

Ответить

Номер ответа: 2
Автор ответа:
 Last_Santa



ICQ: 200700724 

Вопросов: 38
Ответов: 329
 Web-сайт: localhost
 Профиль | | #2
Добавлено: 22.10.03 06:03

Пытался Paste из MSDN, но ошибку словило

Короче так:

DataGrid ловит эту ошибку когда ты работаешь с закладками при динамическом рекордсетете

Вот что по этому поводу предлагает Майкрософт

Steps to Reproduce Behavior

  1. In Visual Basic version 6.0, create a new Data project.

  2. In the frmDataEnv form, add a DataGrid and a CommandButton control.

  3. In the frmDataEnv form module, paste the following code:

    NOTE: Supply the required connection parameters to the cn.Open statement to connect to the SQL Server, and specify a valid table name in the rs.Open statement.
    'General Declarations SectionDim cn As ADODB.ConnectionDim rs As ADODB.RecordsetPrivate Sub Command1_Click()Set cn = New ADODB.ConnectionSet rs = New ADODB.Recordsetcn.Open "Provider=SQLOLEDB;Data Source=<<I>SQL 
Server</I>>;Initial Catalog=<<I>SQL Database</I>>;
User Id=<<I>SQL UserId</I>>;Password=<<I>
SQL Password</I>>"
rs.Open "Select * from <<I>TableName</I>>", 
cn, adOpenDynamic, adLockOptimisticSet DataGrid1.DataSource = rsEnd Sub 
  1. Save and then run the project.

  2. When frmDataEnv is displayed, click the command button.

    You receive the error specified in the "Symptoms" section of this article.

  3. Modify the rs.Open statement in the Command1_Click() event procedure to open a keyset or a static ADO recordset. To do this, replace the constant adOpenDynamic with adOpenKeyset or adOpenStatic.

  4. Save and then run the project.

  5. On frmDataEnv, click the command button.

    The records in the specified table in the OLEDB DataGrid control are displayed.

Ответить

Страница: 1 |

Поиск по форуму



© Copyright 2002-2011 VBNet.RU | Пишите нам