Home > Software engineering >  Help: how to use vb6 datareport of parameters of the stored procedure.
Help: how to use vb6 datareport of parameters of the stored procedure.

Time:09-22

I got a stored procedure with the incoming parameters, test no problem in SQL,


 Private Sub Command1_Click () 
DataEnvironment1. RsCommand1. Open "exec _bb_drwancheng" - debugging to this line is an error,,,,
If DataEnvironment1. RsCommand1. RecordCount & gt; 0 Then
DataReport1. Show 1
The Else
MsgBox "this date there is no record, please choose again!" , vbOKOnly
DataEnvironment1. RsCommand1. Close
End the If
End Sub


Where is the great god, I write wrong?

CodePudding user response:

CodePudding user response:

The Open method (ADO you)


Open the cursor,

Syntax

You. Open Source, ActiveConnection CursorType, LockType, Options

Parameter

Source optional, variable in shape, calculate the variable name Command objects, SQL statements, the table name, a stored procedure call or persistent you filename,

ActiveConnection optional, variable in shape, the effective Connection object variable names; Or a string containing the ConnectionString parameters,

CursorType optional, CursorTypeEnum value, to determine the provider should open when you use the cursor type, can be one of the following constants (see the CursorType property can obtain the definition of these Settings),

Constants that
AdOpenForwardOnly (default) to open the cursor forward only type,
AdOpenKeyset open type cursor keys set,
AdOpenDynamic open dynamic type cursor,
AdOpenStatic open type static cursor,


LockType optional, determine the provider should open when you use lock (concurrent) type LockTypeEnum value, can be one of the following constants (see LockType properties can obtain detailed information),

Constants that
AdLockReadOnly (default) read-only - cannot change data,
AdLockPessimistic conservative type locking (individually) - provider work required to complete to ensure successful edit record, usually by the edit lock immediately when data records,
AdLockOptimistic open lock (individually) - provider USES open lock, lock record only if there is a call the Update method,
AdLockBatchOptimistic open batch update - for batch update mode (as opposed to a immediately update mode),


Options optional, long integer value, used to indicate the provider how to calculate the Source parameters (if it is not representative of the Command object), or to recover from a previously saved you file, you can be one of the following constants (see CommandType property can obtain a detailed description of the list of the top five constants),

Constants that
AdCmdText indication providers should be the Source as command text is defined to calculate,
AdCmdTable instructions ADO to generate SQL queries from named returns all rows in the table in the Source,
AdCmdTableDirect instructions provider changes from the Source named returns all rows in the table,
AdCmdStoredProc indication providers should regard the Source as a stored procedure,
AdCmdUnknown instructions type commands in the Source parameters are unknown,
AdCmdFile instructions should be named in the Source file recovery reserves (save) you,
AdAsyncExecute instructions should be executed asynchronously Source,
AdAsyncFetch instructions in extracting Initial Fetch the Size attribute specified Initial quantity, should be asynchronous extract all the rest of the line, if the line has not been extracted, the main thread will be blocked until the line to available,
AdAsyncFetchNonBlocking indicates the main thread never jam during extraction, if the requested line has not been extracted, the current line automatically moved to the end of the file,


Description

Using the Open method you object can be opened on behalf of the base table, the query results or save before you record the cursor,

Use the optional Source parameter specifies the use of one of the following data sources: the Command object variables, SQL statements, stored procedure, the table name or full path to the file name,

If the Source is the path to the file name, it can be a full path (" c: \ dir \ file RST "), the relative path (".. \ file RST ") or a URL (" http://files/file.rst "),

ActiveConnection parameter corresponds to the ActiveConnection property, and specify in which connection open you object, if the parameter passed the connection of the definition, the ADO to open a new connection using the specified parameters, can be in open after you change the value of the attribute to send updates to other provider, or you can set this property to Nothing (in Microsoft Visual Basic) to you with all providers disconnect,

For the corresponding to you directly the attributes of the object parameters (the Source, the CursorType and LockType), the relationship between parameters and attributes is as follows:

Before you object to open the property is read/write,


Unless the corresponding parameter passed when implement the Open method, otherwise will use attribute set, if transfer parameter, it will cover the corresponding property is set, and the updated attribute set parameter values,


After open you objects, these attributes is a read-only,
Attention for its Source attribute is set to effective Command objects you object, even if you object did not open, ActiveConnection property is read-only,

If send Command objects in the Source parameters and transfer ActiveConnection parameter at the same time, the errors will occur, the ActiveConnection Command objects attribute must have valid Connection object or the Connection string,

If transmitted in the Source parameters is not Command objects, you can use the Options parameter optimization of Source parameters calculation, performance would be reduced if no Options are defined, the reason is ADO you must call the provider to determine whether the parameters for the SQL statements, stored procedures or the name of the table, if has determined the Source type, you can set the Options parameter to indicate ADO directly related to the code, if the Options parameter does not match the Source type, will result in errors,

If there is no connection with you link, the default value of the Options parameter will be adCmdFile, this is the typical case of lasting you object,

If the data source does not return records, the provider will be BOF and EOF attribute set to True at the same time, and do not define the current record position, if the cursor type allows, you can still add new data to the empty object,

On Open you object to complete the operation, can use the Close method to release any relevant system resources, Close the object is not deleted from the memory, it can change its properties Settings and Open it again at a later time using the Open method, object will be completely deleted from the memory, object variables can be set to Nothing,

Before setting ActiveConnection property call not ribbon gymnastics count Open, may increase to you through the field collection Fields create instances, you

If have CursorLocation attribute is set to adUseClient, one of two ways can be used asynchronous retrieval line, it is recommended to use method is to set the Options to adAsyncFetch, or, you can use in the Properties in the collection "asynchronous line set processing" dynamic Properties, but if you do not set the Options parameter to adAsyncFetch, lost may be retrieved events,

Notice the background extraction in MSRemote providers can only get the support by the Open method of the Options parameter,
  • Related