READ UNCOMMITTED Data

Apr 23, 2007

1. In this topic
http://groups.google.com/group/comp...b21516252b65e7c,
someone wrote: "I've implemented SET TRANSACTION ISOLATION LEVEL READ
UNCOMMITTED at the beginning
of a number of stored procedures and, then SET TRANSACTION ISOLATION
LEVEL READ
COMMITTED at the end to minimize the disruption to the application.".
My question is, do you really need to set READ COMMITTED at the end of
stored procedure? What scope does that command affect?

2. Could someone write some real world example where i should never
read uncommitted data... i'm having trouble understanding when i
should and when i should not use it.

View 7 Replies


ADVERTISEMENT

Select With (nolock) OR TransactionScope With Option Read Uncommitted Data

May 29, 2007

Hi Sql gurus :))I've got a question that I couldn't find a satisfying answer on the net.What is the difference between:1) running sql query (select from sth with nolock) with no transaction2) running sql query (select from sth) withing a TransactionScope with option Read Uncommitted dataBasically, both should do the same work. However is anyone aware of any potential problems using any of both approaches ?We use 1) to improve our web application scalability since the system works in such a way that any selects and updates on that table (sth) do not interfere with one another.However, updates are done in a TransactionScope. And when having simultaneous select with nolock and update in a Transaction scope (the select statement has a where clause and returns records that are not updated by the update statement). However sometimes ( we still cannot figure it out when) the select statement returns some records twice.For example, the select should return 1000 records , but (sometimes) it returns 1002 records ( the extra 2 records are copies of some of the original 1000 records).Removing the nolock, makes the problem does not appear - but i want to be 100% sure that nolock is our troublemaker. And if it is - why ?We also have a problem that this particular nolock select sometimes return even less records than it should.I know it sounds impossible but it happens.So anyone who has experience with select with nolock, please share :)Thanks in advance, Yani 

View 4 Replies View Related

Set READ UNCOMMITTED (dirty Read) At Login.

Jul 23, 2005

Is it possible to set READ UNCOMMITTED to a user connecting to an SQL2000 server instance? I understand this can be done via a front endapplication. But what I am looking to do is to assign this to aspecific user when they login to the server via any entry application.Can this be set with a trigger?

View 1 Replies View Related

Appropriate Use Of READ UNCOMMITTED?

Jul 20, 2005

I haven't used the READ UNCOMMITTED transaction isolation levelbefore, and I was wondering if this would be an appropriate use:I have an ID table containing ID numbers that are randomly generatedand need to be unique. There is a stored procedure that potentiallygenerates thousands of these IDs in one execution and inserts theminto the ID table and various other tables. The basic idea is asfollows:Begin TransactionWhile not all IDs generated {GenID:@NewID = GenerateID()If @NewID exists in ID tableGOTO GenIDInsert into ID tableInsert into various other tables}Commit TransactionThe problem occurs when the stored procedure is being run by more thanone process concurrently. The check to see whether @NewID exists inthe ID table will block, waiting for the transaction in the otherprocess to commit.Would this be an appropriate place to use the READ UNCOMMITTEDisolation level to allow different executions of the stored procedureto see what the others are writing into the ID table before thetransactions finish? I only really care that the IDs generated areunique; they're not in sequence or anything like that. Has anyone hadexperience with anything similar?

View 8 Replies View Related

How Does One Set Read-uncommitted On The Entire DB?

Mar 1, 2006

Rather than setting by session I would like to configure the DB as readuncommitted.Thanx Advance.

View 5 Replies View Related

Perf On Read Uncommitted Isolation Level

Jul 5, 2005

Are there really any benefit on using Read Uncommitted Isolation Level or having a NOLOCK hints for retrieve queries when the default Isolation level just Read Committed (not using COM+).  I'm confused why the Community Server uses this technique perhaps for perf issues but I couldn't see any reason why...

View 1 Replies View Related

Locks Caused By Long Lasting SELECT, Could It Be Solved By Read Uncommitted?

Jan 15, 2008

Hi,

Yesterday, we have had a sudden load in our SQL Server 2000 which resulted in several locks. There was not too much time to investigate as we had to rush. A team member had reviewed the processes in EM, Manegement, Current Activity. Looking for blocking processes and killed them.

She told me that as soon as the blocking SPID was killed, another one arose and she had to repeat the operation a dozen of time. When done, the server activity was back to normal. She noticed that more than half of the blocking processes showed that they executed the stored Proc "P_SearchProducts".

We don't own the server and the information on what had happened at that time (batches or resource intensive operations, etc.) is not available for now.

The team suggests that we set the Transaction Isolation Level to Read UNCOMMITTED for this SP. I would like to know better about locks before I go ahead.

P_SearchProducts returns 5 recordsets each one could contains from 1 to 200 rows. To achieve the results, it creates about 10 intermediate tables (SELECT ... INTO #TableX) these temp tables are then used progressively to arrive to the final results. Roughly the volume of these temp tables could be double than the final results. The developer who wrote this SP is not a guru in SQL, there is room for improvement. But here are my questions:

Q1. Could the series SELECT ... INTO #TableX in P_SearchProducts prevent or lock another connection from executing the same SP? If yes, under which conditions?

Q2. Let's assume that P_SearchProducts has a slow execution time. Could it prevent another connection from updating the Product table? And thus leading to a deadlock situation? Something like another transaction (by User2) has obtained lock on most of Product tables, except the Product table which were being slowly read by User1 executing P_SearchProducts. But User1 cannot read the other product tables b/c there are locks by User2.

Q3. If the contention issue was provoked by the slow execution time of many request to exec
P_SearchProducts (let's assume there were suddenly 50 users on the web hitting the search product feature at the same time). Could the Read Uncommitted magically resolve the contention issue, providing we accept the consequences of the dirty read.

Sorry for the long post and thank you in advance for any help.

View 2 Replies View Related

SQL Server 2005 Hanging - Selecting Uncommitted Data

Dec 5, 2006

We have found an issue with using MSS 2005 with odbc connections, some of
our code inserts data, then reselects the data back with a select using a
different handle. This hasn't caused any issues before but in one customer
this causes a lock up. The timeout error doesn't occur as you would expect
if trying to select data that is uncommitted by another user.

Although obviously we could re-code to avoid selecting uncommitted rows, can
anyone tell me why this works sometimes but not others. Some kind of
setting in MSS that we're unaware of maybe. The code works ok on other MSS
2005 & MSS 2000 servers and oracle & sqlbase.

View 1 Replies View Related

Uncommitted Transaction

Oct 19, 2007



Dear friends,

Transaction means the actions user perform in a database, like create table, update, select. Is that correct? Can back up or restore be transactions?

I recently read the tool-kit book and encountered 'uncommitted transactions' many times, esp. in the chapter of 'Backup and Recovery'. For example, today I wanna backup my database by backuping a full database, then three hours later performing a differential backup, and five mins later do transaction log backup. Then I restore those backups following the same sequence. When I restore diferential backup and log backup, I have the option to use one of the three options:

Leave the database ready for use by rolling back the uncommitted transactions. Additional transaction logs cannot be restored. (RESTORE WITH RECOVERY)



Leave the database non-operational, and do not roll back the uncommitted transactions. Additional transaction logs can be restored. (RESTORE WITH NORECOVERY)



Leave the database in read-only mode. Undo uncommitted transactions, but save the undo actions in a standby file so that recovery effects can be reverted. (RESTORE WITH STANDBY)


In the definitions above, 'uncommitted transactions' are all mentioned.

I do not understand why uncommitted transaction happned during or before or after backup( in my opinion, all transactions should be committed before you doing backup)? Can you please give me an example?



Thank you

Julian

View 5 Replies View Related

Pipeline Error-excel Source-data Reader Does Not Read In Meta Data

Apr 16, 2008

Hi all, i got this error:


[DTS.Pipeline] Error: "component "Excel Source" (1)" failed validation and returned validation status "VS_NEEDSNEWMETADATA".

and also this:

[Excel Source [1]] Warning: The external metadata column collection is out of synchronization with the data source columns. The column "Fiscal Week" needs to be updated in the external metadata column collection. The column "Fiscal Year" needs to be updated in the external metadata column collection. The column "1st level" needs to be added to the external metadata column collection. The column "2nd level" needs to be added to the external metadata column collection. The column "3rd level" needs to be added to the external metadata column collection. The "external metadata column "1st Level" (16745)" needs to be removed from the external metadata column collection. The "external metadata column "3rd Level" (16609)" needs to be removed from the external metadata column collection. The "external metadata column "2nd Level" (16272)" needs to be removed from the external metadata column collection.


I tried going data flow->excel connection->advanced editor for excel source-> input and output properties and tried to refresh the columns affected.
It seems that somehow the 3 columns are not read in from the source file?
ans alslo fiscal year, fiscal week is not set up up properly in my data destination?
anyone faced such errors before?

Thanks

View 13 Replies View Related

XML Data Source .. Expression? Variable? Connection? Error: Unable To Read The XML Data.

Feb 23, 2008

RE: XML Data source .. Expression? Variable? Connection? Error: unable to read the XML data.

I want my XML Data source to be an expression as i will be looping through a directory of xml files.

I don't see the expression property or the connection property??

I tried setting the XMLData property to @[User::filename], but that results in:

Information: 0x40043006 at Load XML Files, DTS.Pipeline: Prepare for Execute phase is beginning.
Error: 0xC02090D0 at Load XML Files, XML Source [108]: The component "XML Source" (108) was unable to read the XML data.
Error: 0xC0047019 at Load XML Files, DTS.Pipeline: component "XML Source" (108) failed the prepare phase and returned error code 0xC02090D0.
Information: 0x4004300B at Load XML Files, DTS.Pipeline: "component "OLE DB Destination" (341)" wrote 0 rows.
Task failed: Load XML Files
Information: 0xC002F30E at Bad, File System Task: File or directory "d:jcpxmlLoadjcp2.xml.bad" was deleted.
Warning: 0x80019002 at Package: The Execution method succeeded, but the number of errors raised (2) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.
SSIS package "Package.dtsx" finished: Failure.
The program '[3312] Package.dtsx: DTS' has exited with code 0 (0x0).


Thanks for any help or information.

View 3 Replies View Related

Report Builder - Read Data From SQL Server With Ntext Data Type

Apr 16, 2008

Hi all,

I have a column in SQL server which is of type ntext. Selecting the specific column to view it in report builder, an error message appears with the following description:

- Cannot run this report. The grouping expression 'nameofcolumn' returns the datatype binary. The Grouping Expression cannot return binary data.

Report Builder recognises this as if it was an image...

Thanks in advance!

View 2 Replies View Related

Reporting Services :: How To Read Data (email) From Report In Data Driven SSRS Subscriptions

Jul 28, 2015

get the data from report to create data driven SSRS Subscriptions,

write query :

Running Report:

View 5 Replies View Related

SQL Security :: Making Data Change In Read Only Database Without Letting Other Users Update Data

Aug 6, 2015

I want to make data changes in read_only database , that's why i must set database read_write. While database is at read_write mode, i want to be sure that no one makes change in database.

For this aim, i write the code below, but i suspect that after setting the database read_write, till the setting database
single_user ,is it possible get DML script from another user. Is the code below enough for this operation. Or is there another way?

Reminding: Read_only database can not be set single_user mode. That's why, first you must set database read_write.

The code;

use master
alter database xxx set read_write
with rollback immediate
alter database xxx set single_user
with rollback immediate

use xxx
update  tablexxx set columnxxx=yyy
use master
alter database xxx set read_only
with rollback immediate
alter database xxx set multi_user
with rollback immediate

View 5 Replies View Related

How Can I Read Data From XML-file With Exported Data From MS Access.

Oct 29, 2007


How can I read data from XML-file with exported data from MS Access? Which a dataflow component do I have to use?

Thanks in advance.

View 1 Replies View Related

Read Data From Log

Jul 21, 2006

hi all

how i can read all the querys that send to the server

exmple

insert , update statement need all this statement at the end of the day how can i do that by sqlserver

thanks alot

View 5 Replies View Related

How To Read From Sql Data Set

Sep 13, 2007

Code Snippet
Dim ds As New DataSet
Dim adp As New SqlDataAdapter("Select MaxID,ValueName from tblSettings where ID=1", cn)

adp.Fill(ds)
If IsDBNull(ds.Tables(0).Columns("MaxID")) Then

GetMaxID = 1
Else

GetMaxID = ds.Tables(0).Columns("MaxID")
End If


the ds.Tables(0).Columns("MaxID") showing a value like this. ( Please tell how to read from sql data set)

{System.Data.DataColumn}

AllowDBNull: True

AutoIncrement: False

AutoIncrementSeed: 0

AutoIncrementStep: 1

Caption: "MAxid"

ColumnMapping: Element {1}

ColumnName: "MAxid"

Container: Nothing

DataType: {Name = "Decimal" FullName = "System.Decimal"}

DateTimeMode: UnspecifiedLocal {3}

DefaultValue: {System.DBNull}

DesignMode: False

Expression: ""

ExtendedProperties: Count = 0

MaxLength: -1

Namespace: ""

Ordinal: 0

Prefix: ""

ReadOnly: False

Site: Nothing

Table: {System.Data.DataTable}

Unique: False



View 1 Replies View Related

XML Data Read Help

Sep 12, 2007

I am having issues in figuring out how to read part of an XML file and I'm not sure if it can be done. Any and all help would be appreciated.

I have a file resembled this way:



<btb-root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" btb-num-trans="2"
btb-date="2006-11-09" btb-time="22:40:03" btb-sender="TTT"
btb-receipient="Test">
<btb-request req-method="Asynchronous">
<req-header>
<req-btb-id>Test</req-btb-id>
<req-client-id>Test</req-client-id>
<req-product>Test</req-product>
<req-loan-number>Test</req-loan-number>
</req-header>
<req-property-address>
<addr1>Test DR</addr1>
<city>Test</city>
<state>Test</state>
<zip>Test</zip>
</req-property-address>
<req-borrowers borr-type= "Borrower">
<first-name>Test</first-name>
<last-name>test</last-name>
</req-borrowers>
</btb-request>
</btb-root>

I am in need of extracting the date "2006-11-09" to a field in an import table contained in a sql database. I can pull all the other fields I need but in SSIS retrieving the date is not an option that I currently see. Does anyone know a way around this?

Thanks

View 11 Replies View Related

Converting Read Only Data From SQL 6.5 To SQL 7

Aug 11, 2000

I am using SQL 6.5 and we are going to upgrade to SQL 7. Has anyone
had any experience converting "read only" data? If so, I am looking
for tips and tricks. thanks in advance.

View 1 Replies View Related

Read Data From File Imp Into MS-SQL

Mar 24, 2006

Hi,

Ik like to read data from a file (well formatted) into as MS-SQL database.

What is the best way to do this.

Jim

View 1 Replies View Related

Cannot Re-read Data In Column 2

May 18, 2004

Hi,

I'm connecting to my SQL Server via Java in my Notes environment, but when I try to update my Notes-documents I get an error fra SQL Server saying that it can not re-read data from column 2.

Without being absolutely certain - I'm quite sure that the code is valid.

Does anyone know what the error means ?

Thanks in advance

Kim Hansen

View 1 Replies View Related

Is It Possible If I Want To Read The Backup Data

Jan 28, 2008

hi all
right now , i am still learning how to use sql2005

is it possible if i want to read the backup data without restoring the backup database.? if it possible can you show me how to do it



cheers Arif

arifliminto86

View 6 Replies View Related

How To Share Read Only Data

Jun 15, 2007

Hi,



I'm new to replication. Can anyone help with the following?



I want to publish the specific rows of data that are created on the publisher without accepting changes to those rows from subscribers, but do accept new rows (and changes to those rows) from subscribers.



EG. publisher creates rows 1 and 2 which are published to the subscriber

subscriber creates rows 3 and 4 which are merged back to the publisher

subscriber's updates (or delets) to rows 1 and 2 are not merged back to the publisher



So basically I want the publisher created rows to be published but remain as is whilst allowing subscriber created rows to be merged back to the publisher.



Hope is makes sense.



Thanks in advance,



Seedsy

View 5 Replies View Related

Error: Cannot Read The Next Data Row For The Data Set

Jan 21, 2008

Hi all,

I have noticed quite a few other posts about this error. My feeliing is that it has various causes requiring different remedies. I could not find anything suitable for my situation, so I post this in case someone can offer some tip.

The error happens during subscription report generation.

The following is from the SRS's log file:

ReportingServicesService!runningjobs!14!1/21/2008-10:35:37:: w WARN: Thread pool pressure. Using current thread for a work item.
ReportingServicesService!runningjobs!c!1/21/2008-10:36:28:: i INFO: Adding: 2 running jobs to the database
ReportingServicesService!library!c!1/21/2008-10:41:28:: i INFO: Cleaned 0 batch records, 0 policies, 0 sessions, 0 cache entries, 0 snapshots, 0 chunks, 0 running jobs, 0 persisted streams
ReportingServicesService!runningjobs!c!1/21/2008-10:48:28:: i INFO: RunningJobContext.IsExpired; found expired request
ReportingServicesService!processing!c!1/21/2008-10:48:28:: i INFO: Merge abort handler called for ID=-1. Aborting data sources ...
ReportingServicesService!runningjobs!c!1/21/2008-10:48:28:: i INFO: RunningJobContext.IsExpired; found expired request
ReportingServicesService!processing!8!1/21/2008-10:48:28:: e ERROR: Throwing Microsoft.ReportingServices.ReportProcessing.ProcessingAbortedException: Report processing has been canceled by the user. , ;
Info: Microsoft.ReportingServices.ReportProcessing.ProcessingAbortedException: Report processing has been canceled by the user.
ReportingServicesService!processing!8!1/21/2008-10:48:28:: w WARN: Data set 'ICParamAll': Report processing has been aborted.
ReportingServicesService!processing!19!1/21/2008-10:48:28:: e ERROR: Throwing Microsoft.ReportingServices.ReportProcessing.ProcessingAbortedException: Report processing has been canceled by the user. , ;
Info: Microsoft.ReportingServices.ReportProcessing.ProcessingAbortedException: Report processing has been canceled by the user.
ReportingServicesService!processing!19!1/21/2008-10:48:28:: w WARN: Data source 'eConsole': Report processing has been aborted.
ReportingServicesService!processing!19!1/21/2008-10:48:28:: e ERROR: Throwing Microsoft.ReportingServices.ReportProcessing.ProcessingAbortedException: Report processing has been canceled by the user. , ;
Info: Microsoft.ReportingServices.ReportProcessing.ProcessingAbortedException: Report processing has been canceled by the user.
ReportingServicesService!processing!10!1/21/2008-10:48:28:: e ERROR: Throwing Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: Cannot read the next data row for the data set ICParamAll., ;
Info: Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: Cannot read the next data row for the data set ICParamAll. ---> System.Data.SqlClient.SqlException: Operation cancelled by user.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlDataReader.HasMoreRows()
at System.Data.SqlClient.SqlDataReader.ReadInternal(Boolean setTimeout)
at System.Data.SqlClient.SqlDataReader.Read()
at Microsoft.ReportingServices.DataExtensions.DataReaderWrapper.Read()
at Microsoft.ReportingServices.DataExtensions.MappingDataReader.GetNextRow()
--- End of inner exception stack trace ---



Any tip will be greatly appreciated.

View 2 Replies View Related

How To Get Read Only Control Value Through SQl Data Source

Nov 7, 2006

Hello,
I am using this sql data source control.
<asp:textbox runat="server" id="txtFromDate" ReadOnly="true"></></asp:textbox>
 
<asp:textbox runat="server" id="txtToDate" ReadOnly="true"></asp:textbox>
--------------------------------->
<asp:sqldatasource id="dsClickInfo" runat="server" connectionstring="<%$ ConnectionStrings:activeConnectionString %>"
selectcommand="SProc_GetTransaction" selectcommandtype="StoredProcedure">
<SelectParameters>
<asp:QueryStringParameter QueryStringField="Id" Name="MerchantID" Type="int32" />
<asp:ControlParameter ControlID="txtFromDate" Name="StartDate" PropertyName="Text"
Type="String" DefaultValue="0" />
<asp:ControlParameter ControlID="txtToDate" Name="EndDate" PropertyName="Text"
Type="String" DefaultValue="0" />
</SelectParameters>
 
</asp:sqldatasource>
I abouve code txtFromDate and txtToDate are marked as readonly so sqldatasource is not able to get value from these controls.
How is it possible?
Please help me..

View 3 Replies View Related

.Read() Not Able To Get Data With Special Caracter

Dec 8, 2006

Hi all,
My SQL database has varchar that store names with special caracter like "René". The problem is when I try to get the data back from the database, the .Read() command from the SqlDataReader object is not working. In extra, it does not Throw any error????????
Please help me,
JR

View 3 Replies View Related

Read Image Data From SQL Server

Sep 19, 2007

Here is my task  I am storing pdf's in sql server. I would like to retrieve the binary data from sql server and write the pdf content into an existing aspx page to the appropriate pageview section.  What is the best way to handle this.  The code works below but it loads a new browser with the content.  I need it to appear in it's tabbed section in the original aspx file.  Any assistance you can give me would be greatly appreciated.
 Thanks Jerry
oSQLConn.Open()Dim myreader As SqlDataReader
myreader = myCommand.ExecuteReader
Response.Expires = 0
Response.Buffer = True
Response.Clear()
Do While (myreader.Read())
Response.ContentType = ("application/pdf")Response.BinaryWrite(myreader.Item("img_content"))
Loop

View 5 Replies View Related

Data Read-Consistency During Update

Sep 27, 2007

Hi folks,I have 3 tables of related data in SQL 2000/2005 that receive periodic adds/updates every 30 seconds.I have enabled transactions on all updates, is anything else needed to ensure data consistency during reads in a high # of fetches per second situation?Thanks,johnEdit:Clarification -- I just need the data to be correctly displayed to all users. 

View 2 Replies View Related

How Can I Read From Image Data Type

May 11, 2001

I want to store my MS-Word documents and Excel sheets in the database. So, i have used
the image datatype. Iam not able to download the documents from the database.
i have used getBytes() method. But when i try to download excel sheet document, i get
a error message saying, "File error: data may have been lost".
Can i get some help. can u say how can i put word and excel docs in the database and
retrieve it.
regards,
sathish

View 2 Replies View Related

Read Only User On Data Base

Jan 29, 2004

I'm sure this is a really easy one but I want to create a user with read only access on a sql 2000 database using SQL authentication.

I'm building a little pilot DB system and I have a trainee developer who I want to built me some queries for crystal reports. But I dont want them to be able to amend/delete data or tables etc.

I've created the user but how to I set it to read only. Also will the user still have read only rights if the user has access to the database via enterprize manager/Query analysier.

thanks,

View 5 Replies View Related

Read Commited Data With Out Lock

May 20, 2008

Hi All

Is there a way in SQL to query the data with out locking.

My intention is to read commited data with out locking

Thanks

View 8 Replies View Related

Read Data From Two Files Simultaneously

Oct 17, 2007

Hello,

I have 2 tables EmployeeA(Eng) and EmployeeB(Spanish) kept in seperate mdb's. I want to add the records into Sql Server 2005 table called StateEmployee.

Procedure:
1. Loop through 2 folders..one containing table EmployeeA in mdb and other containing tbl EmployeeB in diff mdb's.
2. Pick a file from EmployeeA and EmployeeB, both at the same time.
3. Count the total no of rows in both files. If equal proceed.
4. Compare the 'employeeid' of one row of employeeA to the employeeid of EmployeeB.
5. If employee id matches, load both the rows in Sql server else file it to the error table.
6. Loop through all rows simultaneously till end of row.
7. Go to next mdb.

How do i go about this step by step. I am fairly new to SSIS.

View 1 Replies View Related

Read Binary Data From SQL Server

Oct 19, 2007

hello.
i have a _CommandPtr that has the type CommandTypeEnum::adCmdTex, and the CommandText a query("Select * from Table_1") and this select returns one row that has a binary data in it.




Code Block

_CommandPtr pCommand;
//Create the C++ ADO Command Object

pCommand.CreateInstance(__uuidof(Command));

pCommand->ActiveConnection = this->pConnection;

//Make the ADO C++ command object to accept stored procedure

pCommand->CommandType = CommandTypeEnum::adCmdText;

//Tell the name of the Stored Procedure to the command object

pCommand->CommandText = _bstr_t("select * from Table_1");

//get recordset
pRecordset = pCommand->Execute(NULL,NULL,CommandTypeEnum::adCmdText);

BYTE* buffer = NULL;
if(pRecordset != NULL)
{

while (!pRecordset->GetEndOfFile())
{

VARIANT var = pRecordset->Fields->GetItem("test")->Value;

void * pData = NULL;
SafeArrayAccessData(var.parray, &pData);
long size = GetArraySize(var, NULL);
buffer = new BYTE[size];
memcpy(buffer, pData, size);
SafeArrayUnaccessData(var.parray);
pRecordset->MoveNext();
}
pRecordset->Close();
}

where:



Code Block
long GetArraySize(const VARIANT& var, long * nElems)
{

if ( !(var.vt & VT_ARRAY) ) return -1;

long size = 0;
long dims = SafeArrayGetDim(var.parray);
long elemSize = SafeArrayGetElemsize(var.parray);
long elems = 1;
for ( long i=1; i <= dims; i++ )
{

long lbound, ubound;
SafeArrayGetLBound(var.parray, i, &lbound);
SafeArrayGetUBound(var.parray, i, &ubound);
elems *= (ubound - lbound + 1);
}
if ( nElems ) *nElems = elems;
size = elems*elemSize;
return size;
}






I enter in VARIANT var = pRecordset..... and if gives me a value... but when I put it in Memory explorer in VS, i only see this data " fe ee fe ee fe ee fe ee fe ee fe ee fe ee ...fe ee" and of course it brakes at
SafeArrayGetLBound(var.parray, i, &lbound);

Can someone tell me where I am doing a very bad thing?

P.S. I was able to read the binary data from the server using C#.NET 2.0.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved