SQLCommand's Transaction Property Goes Null On Failure

Sep 20, 2007

I've written some provider independent code that dynamically generates and loads DbCommands with data via Parameters and executes them within a transaction. Everything works fine until an exception occurs and then the DbCommand.Transaction property that was set goes to null,  effectively killing any chance of rolling back the transaction. I've noticed this only happens when the executed command is of type SqlCommand. The OracleCommand mainitains its link to the set transaction of failure. Upon further investigation, I found that this only occurs when parameters are used but not if I dynamically generate the insert statement as a string.. For instance:
SqlConnection conn = new SqlConnection(connectionString);
conn.Open();
SqlTransaction transaction = conn.BeginTransaction();
SqlCommand comm = new SqlCommand();
comm.Connection = conn;
comm.Transaction = transaction; 
command.commandText = "INSERT INTO Table1 Values (1, 2, 3)";
command.ExecuteNonQuery(); 
If I execute that and it fails the command.Transaction property will remain set to transaction, but in this scenario:
 
SqlConnection conn = new SqlConnection(connectionString);
conn.Open();
SqlTransaction transaction = conn.BeginTransaction();
SqlCommand comm = new SqlCommand();
comm.Connection = conn;
comm.Transaction = transaction; 
comm.commandText = "INSERT INTO Table1 Values (@Col1,@Col2, @Col3)";
comm.Parameters.add(new SqlParameter("@Col1", 1); 
comm.Parameters.add(new SqlParameter("@Col2", 2);
comm.Parameters.add(new SqlParameter("@Col3", 3);

 
comm.ExecuteNonQuery();
 
Upon failing the comm.Transaction property gets somehow goes null and the Connection property of the transaction object also goes null.
Any ideas on why this only happens with a SqlCommand but no other DbCommand?

 
 

 

 
 
 

View 4 Replies


ADVERTISEMENT

What Property Should I Assign To My Sqlcommand ?

Apr 2, 2008

what property should i assign to myPuzzleCmd2 ? 
 
myConnection.Open()
 Dim myPuzzleCmd2 As New SqlCommand("GetRandomCode", myConnection)
 
myPuzzleCmd2.CommandType = CommandType.StoredProcedure
 Dim retLengthParam As New SqlParameter("@Length", SqlDbType.TinyInt, 6)
retLengthParam.Direction = ParameterDirection.Input
 
myPuzzleCmd2.Parameters.Add(retLengthParam)
 Dim retRandomCode As New SqlParameter("@RandomCode", SqlDbType.VarChar, 30)
 
retRandomCode.Direction = ParameterDirection.Output
 
myPuzzleCmd2.Parameters.Add(retRandomCode)
 
Try
 Dim reader As SqlDataReader = myPuzzleCmd2.ExecuteReader()
myPuzzleCmd.ExecuteNonQuery()Catch ex As Exception
 
myPuzzleCmd2 = Nothing
 Session.Remove("RandomCode")
 HttpContext.Current.Session("RandomCode") = myPuzzleCmd2("@RandomCode")        <  ---------       Over here
 Finally
myConnection.Close()
End Try

View 7 Replies View Related

Setting Expressions In Datareader's SQLCommand Property Dynamically

Sep 19, 2006

Hi all,

I have been playing with integration services for a few days and at the moment, its up there with my list of software that I find ......painful.

What I am trying to do is read different tables from my one SQL database, then populate my Access database with its data.

I have put a foreach loop which goes through a collection SQL statements that I have entered into it. It first assigns it to a string variable called tablenameVar which contain statements such as "Select * from Terminals". Then the datareader is supposed to execute it based on the connectstring which never changes, and the SQLCommand value which I passed using the variable @[User::tableName]. However when I try to run it, I'm getting this error.

TITLE: Package Validation Error
------------------------------

Package Validation Error

------------------------------
ADDITIONAL INFORMATION:

Error at Data Flow Task [DTS.Pipeline]: "component "DataReader Source" (1)" failed validation and returned validation status "VS_NEEDSNEWMETADATA".

Error at Data Flow Task [DTS.Pipeline]: One or more component failed validation.

Error at Data Flow Task: There were errors during task validation.

(Microsoft.DataTransformationServices.VsIntegration)

------------------------------
BUTTONS:

OK
------------------------------


Does anyone have an idea of what I should do? or maybe a better way to do it? I appreciate you guys for taking a time to look at this.

Thanks,

Joseph

View 1 Replies View Related

Any Improvements To This: Cannot Apply Value Null To Property Login: Value Cannot Be Null.

Mar 26, 2007

Looks like there was a fix and then I read this fix is not a fix. Does anyone know how this can be rectified? Does it mean that only Windows authentiation is the only way it works. The Software is over 2 years old, there are no excuses.

View 1 Replies View Related

Error 8525: Distributed Transaction Completed. Either Enlist This Session In A New Transaction Or The NULL Transaction.

May 31, 2008

Hi All

I'm getting this when executing the code below. Going from W2K/SQL2k SP4 to XP/SQL2k SP4 over a dial-up link.

If I take away the begin tran and commit it works, but of course, if one statement fails I want a rollback. I'm executing this from a Delphi app, but I get the same from Qry Analyser.

I've tried both with and without the Set XACT . . ., and also tried with Set Implicit_Transactions off.

set XACT_ABORT ON
Begin distributed Tran
update OPENDATASOURCE('SQLOLEDB','Data Source=10.10.10.171;User ID=*****;Password=****').TRANSFERSTN.TSADMIN.TRANSACTIONMAIN
set REPFLAG = 0 where REPFLAG = 1
update TSADMIN.TRANSACTIONMAIN
set REPFLAG = 0 where REPFLAG = 1 and DONE = 1
update OPENDATASOURCE('SQLOLEDB','Data Source=10.10.10.171;User ID=*****;Password=****').TRANSFERSTN.TSADMIN.WBENTRY
set REPFLAG = 0 where REPFLAG = 1
update TSADMIN.WBENTRY
set REPFLAG = 0 where REPFLAG = 1
update OPENDATASOURCE('SQLOLEDB','Data Source=10.10.10.171;User ID=*****;Password=****').TRANSFERSTN.TSADMIN.FIXED
set REPFLAG = 0 where REPFLAG = 1
update TSADMIN.FIXED
set REPFLAG = 0 where REPFLAG = 1
update OPENDATASOURCE('SQLOLEDB','Data Source=10.10.10.171;User ID=*****;Password=****').TRANSFERSTN.TSADMIN.ALTCHARGE
set REPFLAG = 0 where REPFLAG = 1
update TSADMIN.ALTCHARGE
set REPFLAG = 0 where REPFLAG = 1
update OPENDATASOURCE('SQLOLEDB','Data Source=10.10.10.171;User ID=*****;Password=****').TRANSFERSTN.TSADMIN.TSAUDIT
set REPFLAG = 0 where REPFLAG = 1
update TSADMIN.TSAUDIT
set REPFLAG = 0 where REPFLAG = 1
COMMIT TRAN


It's got me stumped, so any ideas gratefully received.Thx

View 1 Replies View Related

SSIS, Distributed Transaction Completed. Either Enlist This Session In A New Transaction Or The NULL Transaction.

Feb 22, 2007

I have a design a SSIS Package for ETL Process. In my package i have to read the data from the tables and then insert into the another table of same structure.

for reading the data i have write the Dynamic TSQL based on some condition and based on that it is using 25 different function to populate the data into different 25 column. Tsql returning correct data and is working fine in Enterprise manager. But in my SSIS package it show me time out ERROR.

I have increase and decrease the time to catch the error but it is still there i have tried to set 0 for commandout Properties.

if i'm using the 0 for commandtime out then i'm getting the Distributed transaction completed. Either enlist this session in a new transaction or the NULL transaction.

and

Failed to open a fastload rowset for "[dbo].[P@@#$%$%%%]". Check that the object exists in the database.

Please help me it's very urgent.

View 3 Replies View Related

Distributed Transaction Completed. Either Enlist This Session In A New Transaction Or The NULL Transaction.

Feb 6, 2007

I am getting this error  :Distributed transaction completed. Either enlist this session in a new
transaction or the NULL transaction. Description:
An unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the error and
where it originated in the code. Exception Details:
System.Data.OleDb.OleDbException: Distributed transaction completed. Either
enlist this session in a new transaction or the NULL transaction.have anybody idea?!

View 1 Replies View Related

Distributed Transaction Completed. Either Enlist This Session In A New Transaction Or The NULL Transaction.

Dec 22, 2006

i have a sequence container in my my sequence container i have a script task for drop the existing tables. This seq. container connected to another seq. container. all these are in for each loop container when i run the package it's work fine for 1st looop but it gives me error for second execution.

Message is like this:

Distributed transaction completed. Either enlist this session in a new transaction or the NULL transaction.

View 8 Replies View Related

Distributed Transaction Completed. Either Enlist This Session In A New Transaction Or The NULL Transaction. (HELP)

Jan 8, 2008

Hi,

i am getting this error "Distributed transaction completed. Either enlist this session in a new transaction or the NULL transaction.".

my transations have been done using LINKED SERVER. when i manually call the store procedure from Server 1 it works but when i call it through Service broker it dosen't work and gives me this error.



Thanks in advance.


View 2 Replies View Related

The Best Overloaded Method Match For 'System.Data.SqlClient.SqlCommand.SqlCommand Error

Sep 21, 2006

Hi,I'm new to ASP.NET, and am currently looking into XML.I'm trying to write XML using data from an SQL Server 2000 table.  But I seem to be getting the following error regarding the SQL Server connection:Compiler Error Message: CS1502: The best overloaded method match for 'System.Data.SqlClient.SqlCommand.SqlCommand(string, System.Data.SqlClient.SqlConnection)' has some invalid argumentsSource Error:Line 23: {
Line 24: SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter();
Line 25: mySqlDataAdapter.SelectCommand = new SqlCommand(queryString, connString);
Line 26: mySqlDataAdapter.Fill(myDataSet);
Line 27: return myDataSet;Source File: c:InetpubwwwrootmappingcreateGeoRSSFile.aspx.cs    Line: 25 This is my code:using System;
using System.Data;
using System.Data.SqlClient ;
using System.Configuration;
using System.Collections;
using System.Text;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml;

public partial class createGeoRSSFile : System.Web.UI.Page
{
protected void Page_Load(object sender, DataSet myDataSet, EventArgs e)
{
string connString = "server=SQLSERV1;database=Historical_Statistics;UID=dbuser;PWD=Password";
string queryString = "SELECT Town, PostCode, Latitude, Longitude FROM UKPostCodes";

using (SqlConnection mySqlConnection = new SqlConnection(connString))
{
SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter();
mySqlDataAdapter.SelectCommand = new SqlCommand(queryString, connString);
mySqlDataAdapter.Fill(myDataSet);
return myDataSet;
}

// Create a new XmlTextWriter instance
XmlTextWriter writer = new XmlTextWriter(Response.OutputStream, Encoding.Unicode);

// Start writing!
writer.WriteStartDocument();
writer.WriteStartElement("item");

// Creating the <town> element
writer.WriteStartElement("town");
writer.WriteElementString("PostCode",myDataSet .Tables[1].Columns("PostCode"));
writer.WriteElementString("geo:lat",myDataSet.Tables[1].Columns("Latitude"));
writer.WriteElementString("geo:lon", myDataSet.Tables[1].Columns("Longitude"));
writer.WriteEndElement();

writer.WriteEndElement();
writer.WriteEndDocument();
writer.Flush();
writer.Close();

}
}What seems to be causing this error?Thanks. 

View 4 Replies View Related

Hotfix For Cannot Apply Value Null To Property Login Error Available?

Feb 24, 2006

It appears that Microsoft has fixed the "Cannot apply value null to property Login" bug in SSIS, according to this web page:

Click here for bug details

Question: is there a hotfix available for download?



View 1 Replies View Related

Passing An SQLcommand To A Asp.net Web Service As Sqlcommand

Feb 10, 2008

Hi

Is it possible To pass an SQL command to a ASp.net web service as system.data.SQLclient.sqlcommand?


That means is ispossible to pass the actuall sql command instead of just the string?

If yes how can you do that??

Cheers

View 1 Replies View Related

Failure On Null Aggregation

Dec 20, 2007

Hi all,

my package is failing every now and then on the following error:

SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005.
An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x00040EDA Description: "Warning: Null value is eliminated by an aggregate or other SET operation.".
yes, I do have a null aggregation, but in all my tests this didn't cause a failure...
anyone had experience with this?

Thanks.

View 13 Replies View Related

Transaction Log Backup Failure

Aug 4, 2000

I seem to have a problem with my SQL Server log backup system. First I was receiving alerts that the log file was filling up, so I increased it from 3Mb to 150Mb, but then I got another alert saying the same thing, later on I got an alert saying that the log backup had failed. I then decided to truncate the log and do a full backup after as suggested, however this did not work, I don't know if I am doing something wrong, this is really confusing and frustrating.

View 1 Replies View Related

Transaction Log Backup Failure

Aug 15, 1999

I have scheduled transaction log backups to occur every 15 minutes with database backups every sunday at 1.00AM and differential db backups every day at 1.30AM.

While viewing the job history of the transaction log backups through enterprise manager, I noticed that one transaction log backup had failed at 1.00AM on sunday. The error message was,

"Backup, CHECKALLOC, bulk copy, SELECT INTO, and file manipulation (such as CREATE FILE) operations on a database must be serialized. Reissue the statement after the current backup, CHECKALLOC, or file manipulation operation is completed. [SQLSTATE 42000] (Error 3023) Backup or restore operation terminating abnormally. [SQLSTATE 42000] (Error 3013). The step failed. "

Please let me know what the error message implies. Will there be any problem if the transaction log backup takes place at the same time as the full database backup or diff. db backup?

Thankyou.
Praveena

View 2 Replies View Related

Failure Of Transaction Log Backups

Jan 14, 2002

The Transaction log backups that I do for the msdb and master databases ALWAYS fail. The full database backups always succeed. Are the master and msdb databases not supposed to have their transaction logs backed up? Jobs where configured thru the Database Maintenance wizard. Will the jobs fail if nothing has changed in either database? I am also confused by the fact that database and log backups for the model database ALWAYS work when I expect their to be little if none activity in that database.

Thanks in advance,

Riley

View 2 Replies View Related

Distributed Transaction Failure

May 10, 2006

I’m attempting to insert the result set from a remote query into a local table and I’m getting the following error:

Msg 8501, Level 16, State 1, Line 1
MSDTC on server 'REMOTESVR' is unavailable.
OLE DB error trace [OLE/DB Provider 'SQLOLEDB' ITransactionJoin::JoinTransaction returned 0x8004d01c].
Msg 7391, Level 16, State 1, Line 1

The operation could not be performed because the OLE DB provider 'SQLOLEDB' was unable to begin a distributed transaction.


MSDTC is running on both servers. Has anyone ever seen this or have any insight into the cause?


The code that I’m trying to run is:

create table msver
(
[Index] int,
[Name] varchar(30),
Internal_Value varchar(20),
Character_Value varchar(512)
)

insert into msver
exec ('exec [REMOTESVR].master.dbo.xp_msver')


Note that the remote query works fine.

Thanks!
Eric

View 3 Replies View Related

Transaction Log Backup Failure

May 26, 2008

Hi

I have a job that runs full backs and that was successfull but all my transaction log backups failed. This is the error message i get:

1.VDI error 1010: Failed to get configuration from server. Check that the SQL Server instance is running, and that you have the SQL Server Systems Administrator server role. Error code: (-2139684861: The api was waiting and the timeout interval had elapsed.)

2.SQL error 3013: BACKUP LOG is terminating abnormally.

3.SQL error 4214: BACKUP LOG cannot be performed because there is no current database backup.


Please assist.

View 6 Replies View Related

Data Conversion - NULL Datetime Causes Failure

Jul 9, 2007

Hi,



I have a flat file source and am bringing it into an OLE DB Destination connected to a SQL Server 2005 database. Since I am bringing in the data via a flat file, I have a conversion step in the data flow, which uses a "Data Conversion" transformation to convert each column to the appropriate destination data type.



When I run my SSIS package, if the datetime column in the flatfile is NULL, then the Data Conversion step fails. I have my Data COnversion step set to redirect error rows to an error output. So, I get all the rows with populated datetime values in the intended destination, and none of the rows with null datetime values (these go to the error destination.)



This is a problem! I need to make sure all valid rows fall through. It seems very odd to me that a NULL datetime could not be converted to a datetime data type. This makes no sense, since a datetime column can naturally hold NULL, just like any other type. So, my question is: is this a bug??? It seems to me it is. I can't believe this would be the desired behavior?!



Microsoft: please let us know whether this is expected behavior. If so, then what would the desired workaround be?



Thanks

View 5 Replies View Related

For Each Loop Failure When Some Values In Recordset Are NULL

Sep 15, 2006

I have a for each loop container that is performing various tasks as it loops through a record set. Some of the values from the recordset are NULL at times and this causes the FELC to fail because it is unable to map the variables that have NULL values.

Is there something I can set to have it accept the NULLS or something I can change about the variables themselves. This is valid data that still needs to be processed. There are other attributes that have data in the record.

Here are samples of my error messages:

Error: ForEach Variable Mapping number 19 to variable "User::varTransactionReference" cannot be applied.

Error: ForEach Variable Mapping number 20 to variable "User::varFlowStartDate" cannot be applied.

Error: ForEach Variable Mapping number 26 to variable "User::varCancelFee" cannot be applied.



Thanks in advance.

SK



View 2 Replies View Related

MSDB Transaction Log Backup Failure

Feb 17, 2003

I'm getting "Executed as user: SPIESQLService. sqlmaint.exe failed. [SQLSTATE 42000] (Error 22029). The step failed." on the TRN backup portion of the maintenance plan for the msdb and model databases. On review of files created it's clear that the msdb trn log backup is failing, but there's no other error to indicate the underlying problem.

Suggestions?

TIA,

Al

View 1 Replies View Related

Adding Transaction Causes Connection Failure?

May 14, 2007

I have some tables that I need to wipeout and reload once per day. So I have created a T-SQL task that does a truncate table, then a data flow task, then a update statistics task. Running those works fine, but as soon as I put them all into a sequence container and set the container to require transactions, the first step gets a connection failure. "Failed to acquire connection "<name>". Connection may not be configured correctly or you may not have the right permissions on this connection". I am using a .Net SQLClient data provider for the T-SQL task and in the data flow task I have to use a OLEDB provider so that I can run the task locally in development.



Is there something I am doing wrong or is there some other way to handle truncate, load, update stats all in a transaction?



Thanks.

Tim

View 8 Replies View Related

Bogus FK Violation On Insert - Transaction Failure?

May 23, 2008

I have 14 beta users on a PPC application based on .NET CF 2.0 and SQLCE 3.0. Data is sent back and forth as XML via web services. One user cannot complete the initial download - he receivces the following error every time:

A foreign key value cannot be inserted because a corresponding primary key value does not exist. [ Primary key constraint name = FK_jobtask_job ]


I have run the queries for this user and verified that no task has a JobID that is not in the Job table. I am also able to successfully complete the initial download as the user in the Mobile 5.0 PPC emulator. His device has 130 MB of free storage space and 20 MB program space (my emulator has 11 MB storage and 70 MB program).

The initial download for this user is about 14 MB of XML, all of which will be inserted in the SDF under a single transaction. Although the SDF was only 4.75 MB on my emulator (after successfully downloading as this user) I am wondering if there is an unreported error in the handling of the transaction or its temp file that causes the error he receives. Frankly, I've run out of ideas. Does anyone have details about transaction temp file size limits or any other ideas that might lead to a resolution?

Scott

View 3 Replies View Related

Restore Database FROM MDF/LDF, Then Apply Transaction Log From POint Of Failure? Is It POssible?

May 18, 2005

If I have a database backup from sunday, and a failure occurs monday...  Can the backup .mdf and .ldf files be attached, and the backup log after the point of failure be applied to them?
The problem I am having is it looks like you can only restore from a .bak file, and then apply the log at the point of failure.  IT doesn't look like you can restore the .ldf/.mdf files, and then apply the backup log from the point of failure.
 
Can someone please help?  I'm in desparate need of fixing this !
 
Thanks,dp
 
 

View 1 Replies View Related

Changing Code Page Property Using Property Expression Doesn't Work

Jun 16, 2006

I am having problems exporting data into a flat file using specific code page. My application has a variable "User::CodePage" that stores code page value (936, 950, 1252, etc) based on the data source. This variable is assigned to the CodePage property of desitnation file connection using Property expression.

But, when I execute the package, the CodePage property of the Destination file connection defaults to the initial value that was set for "User:CodePage" variable in design mode. I checked the value within the variable during runtime and it changes correctly for each data source. But, the property of the destinatin file connection doesn't change and results in an error.

[Flat File Destination [473]] Error: Data conversion failed. The data conversion for column "Column01" returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page.".

[DTS.Pipeline] Error: The ProcessInput method on component "Flat File Destination" (473) failed with error code 0xC02020A0. The identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running.

If I manually update the variable with correct code page and re-run the ETL, everything works fine. Just that it doesn't work during run-time mode.

Can someone please help me resolve this.

Thanks much.

View 5 Replies View Related

Value Of A Readonly Property Of Custom Task Is Not Updated In Property Window

Apr 17, 2008

Hi,

I developed a simple custom control flow component which has several read/write properties and one readonly property (lets call it ROP) whichs Get method simple returns the value of a private variable (VAR as string). In the Execute method the VAR has a value assigened. When I put the value of ROP or VAR into MsgBox I can see the correct value. However when I execute the component I can not see the value of the ROP in the property window. I see the property but its value is empty string. For example when I put a breakpoint to postexecute or check the property before click OK in a MsgBox I would expect that the property value would be updated in SSIS as well. Is there a way how to display correct values of custom tasks properties in property window?

Thanks for any hints.

View 3 Replies View Related

Analysis :: If Parent Is NULL But Child Have Transaction Will Not Come In MDX Query

Oct 15, 2015

I have parent child dimension,

for customer id-101
---------H1-p  Sales Value-50
---c1-c  Sales Value-100
---c2-c Sales Value-200

If I will see H1 Value then it show =350

But when my head office is not exists for a customer but Child is exist i want to see data of child Aggregate value.

Example

for Customer ID-102
NO --H1 it is null
----c1 c sales Value -200
---c2 c Sales Value-50

When I want to see value of 102 at H1 leval it show me 250 . even H1 is  null.

View 3 Replies View Related

(URGENT) Cannot Be Written To The Property. The Expression Was Evaluated, But Cannot Be Set On The Property

May 7, 2008

Untill recently I had a smooth running SSIS package,but suddenly it throws error syaing
"OnError,,,,,,,The result of the expression

"@[User:trTextFileImpDirectory] +"SomeTextStringHere"+ @[User:trANTTextFileName] +(DT_STR,30,1252) @[User:taging_Date_Key]+ "SomeTextStringHere"
" on property "ConnectionString" cannot be written to the property. The expression was evaluated, but cannot be set on the property."

I have child SSIS package running under a parent package (through execute package task)

I have few flat file connection managers in child package for text file import , in which I am building text file path dynamically at run time by assigning an expression in connection string property of connection manager.
The Expression is as follows



"@[User:trTextFileImpDirectory] +"SomeTextStringHere."+ @[User:trANTTextFileName] +(DT_STR,30,1252) @[User:taging_Date_Key]+ +"SomeTextStringHere"

Where @[User:trTextFileImpDirectory] is a variable which contains path of directory containg text
files.Value in this variable is assigned at runtime from parent package's variable,which in turns fetch
value from a configuration file on local server.

With my current configuration this path has been configured to some other server's directory over network ( I.e my package picks text files from some other servers folder over network)

While
"Some string here"+ @[User:trANTTextFileName]" part of file name string.

(DT_STR,30,1252) @[User:taging_Date_Key] Contain the date of processing ,value in this variable is also picked up at run time from parent package variable.

1) So can someone give me some insight into possible reason of failures.
2) Is it possible that problem arises if directory (from which I m picking text files) is assigned password or is there exist some problem in accessing forlders over network ?
3) Or there can be some problem in package configuration at design time( I.e where I m assigning value in variable from parent package vriables)?




View 10 Replies View Related

Problem With Isnull. Need To Substitute Null If A Var Is Null And Compare It To Null And Return True

Sep 20, 2006

Hey. I need to substitute a value from a table if the input var is null. This is fine if the value coming from table is not null. But, it the table value is also null, it doesn't work. The problem I'm getting is in the isnull line which is in Dark green color because @inFileVersion is set to null explicitly and when the isnull function evaluates, value returned from DR.FileVersion is also null which is correct. I want the null=null to return true which is why i set ansi_nulls off. But it doesn't return anything. And the select statement should return something but in my case it returns null. If I comment the isnull statements in the where clause, everything works fine. Please tell me what am I doing wrong. Is it possible to do this without setting the ansi_nulls to off??? Thank you

set ansi_nulls off


go

declare

@inFileName VARCHAR (100),

@inFileSize INT,

@Id int,

@inlanguageid INT,

@inFileVersion VARCHAR (100),

@ExeState int

set @inFileName = 'A0006337.EXE'

set @inFileSize = 28796

set @Id= 1

set @inlanguageid =null

set @inFileVersion =NULL

set @ExeState =0

select Dr.StateID from table1 dR

where

DR.[FileName] = @inFileName

AND DR.FileSize =@inFileSize

AND DR.FileVersion = isnull(@inFileVersion,DR.FileVersion)

AND DR.languageid = isnull(@inlanguageid,null)

AND DR.[ID]= @ID

)

go

set ansi_nulls on

View 3 Replies View Related

Referencing One Item's Hidden Property In Order To Set Another's Hidden Property

Feb 15, 2007

Hello,

I have a group I'll call G4.

The header table row for G4 contains 3 textboxes containing the sums of the contents within G4. The header table row for G4 is visible while it's contents, including the G4 footer table row, is kept invisible until the report user drills down into the group.

When the report user drills down into G4 the footer table row becomes visible and the sums of the contents of the group are displayed for a second time.

At this point I want the sums in the header to be set to invisible when the sums in the footer are made visible by the drilldown.

When I try to reference the hidden property of textbox66 in the G4 footer in order to set the hidden property of header textbox57 in the G4 header I get to this point...

=IIF(reportitems!textbox66.

When it fails to give me an option of choosing the .Hidden property and instead only gives me a .Value.

If I complete the IIF statement manually so that it spells out .....

=IIF(ReportItems!Textbox66.Hidden = False, True, False)

...the report chokes on it.

So my question is, how do I reference the hidden property of one or more textboxes in a group to use as condition checks to set the hidden property of another textbox in that same group?

Thank you for any help you can provide. We are only now beginning to implement reporting services and I have not yet had the chance to research this in greater detail for lack of time.



View 1 Replies View Related

Help With Sqlcommand...

Jan 8, 2007

Hi guys. I'm having trouble declaring an sqlcommand. What I want to do is declare a global sqlcommand and I would want this sqlcommand to vary depending on the conditions on my page_load.
Here's the code....
  
 Dim p_s_syounin2 As New SqlCommand 
Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
If (Session("syozokubu_id") = 20) And (Session("syozokuka_id") = 21) And ((Session("kaikyuu_id") = 23)) Then
 p_s_syounin2 = ("INSERT INTO (p_s_syounin2) SELECT syain_hnm FROM TR_syainID WHERE TR_syainID.syozokubu_id=20 AND TR_syainID.syozokuka_id=21 AND TR_syainID.kaikyuu_id=23, cnn")   '''' THIS DOES NOT WORK!
End If
End Sub
 p_s_syounin2 .ExecuteNonQuery()
 
What is the correct way of declaring  p_s_syounin2?
Thanks.
 
Best Regards,
Audrey

View 5 Replies View Related

Re-use SqlCommand Object

Oct 19, 2006

Is it ok to re-use a SqlCommand object?  In a method, I am executing 2 separate parameterized sql statements.  Before I run the second, I will clear the command objects parameters.(command.parameters.clear())  I'm just checking to see if it is good coding practice or not. thanks,SC

View 2 Replies View Related

XML Parameter In Sqlcommand

Mar 6, 2007

I created an xmldocument which I would like to insert in a db field with the data type XML.The following code is giving me the error:System.Data.SqlClient.SqlException: XML parsing: line 1, character 38, unable to
switch the encoding             SqlCommand cmdUpdate = new SqlCommand("sp_AddHistory", sqlConnection);            cmdUpdate.CommandType = CommandType.StoredProcedure;            cmdUpdate.Parameters["@FieldsChanged"].Value = xmlDoc.innerXML; // don't know whether this is good             cmdUpdate.ExecuteNonQuery(); innerXML:<?xml version="1.0" encoding="utf-8"?><Fields>    <Field>        <FieldName>comp_Area</FieldName>        <OldValue>Area 52</OldValue>        <NewValue>Area 51</NewValue>    </Field></Fields> The XML seems fine.. any ideas? 

View 3 Replies View Related







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