473,419 Members | 1,839 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,419 software developers and data experts.

Intermittent SQL corruption from ExecuteScalar

We are having an intermittent problem using an ExecuteScalar command on a
asp.NET page accessing SQL Server. 2 characters of the sql statement get
intermittently altered. The code looks as follows:

SqlCommand command = new SqlCommand("SELECT fkOWSStatusID FROM
vwUsersCleanups WHERE pkCleanupID = 123", connection);
object nReturn = command.ExecuteScalar();

About 10% of the time, the 'rs' in vwUsersCleanups get altered into
unrecgonizable characters. The other 90% of the time, everything works just
fine. I have put a Trace method just before the ExecuteScalar() to verify
the sql statement is correct. It always looks just fine. However, in SQL
Profiler, in the BatchStarting Event, the Select statement is corrupt. I
have applied the most recent service pack for MDAC 2.7, reinstalled the .NET
Framework (version 1.1), and deleted and recreated the view all to no avail.
This occurs on 2 of our IIS servers. All other IIS servers we try it on
works fine. This seems to eliminate any bad build problems.

Nov 18 '05 #1
2 1845
Is there a database collation difference? If you are using more than one
database server or database. If there is a colation difference, you will get
bad SQL statements.

"Mike Krajewski" wrote:
We are having an intermittent problem using an ExecuteScalar command on a
asp.NET page accessing SQL Server. 2 characters of the sql statement get
intermittently altered. The code looks as follows:

SqlCommand command = new SqlCommand("SELECT fkOWSStatusID FROM
vwUsersCleanups WHERE pkCleanupID = 123", connection);
object nReturn = command.ExecuteScalar();

About 10% of the time, the 'rs' in vwUsersCleanups get altered into
unrecgonizable characters. The other 90% of the time, everything works just
fine. I have put a Trace method just before the ExecuteScalar() to verify
the sql statement is correct. It always looks just fine. However, in SQL
Profiler, in the BatchStarting Event, the Select statement is corrupt. I
have applied the most recent service pack for MDAC 2.7, reinstalled the .NET
Framework (version 1.1), and deleted and recreated the view all to no avail.
This occurs on 2 of our IIS servers. All other IIS servers we try it on
works fine. This seems to eliminate any bad build problems.

Nov 18 '05 #2
As far as I can tell, all default collations, and collations on the
procedures, tables, views, and columns all have SQL_Latin1_General_CP1_CI_AS.
We havn't dealt with changing collations at all. The really strange thing
is that it is so intermittent. Those 2 characters will be incorrect, but if
you refresh your browser then they will be correct the next time and the page
will show up correctly.

"MikeL" wrote:
Is there a database collation difference? If you are using more than one
database server or database. If there is a colation difference, you will get
bad SQL statements.

"Mike Krajewski" wrote:
We are having an intermittent problem using an ExecuteScalar command on a
asp.NET page accessing SQL Server. 2 characters of the sql statement get
intermittently altered. The code looks as follows:

SqlCommand command = new SqlCommand("SELECT fkOWSStatusID FROM
vwUsersCleanups WHERE pkCleanupID = 123", connection);
object nReturn = command.ExecuteScalar();

About 10% of the time, the 'rs' in vwUsersCleanups get altered into
unrecgonizable characters. The other 90% of the time, everything works just
fine. I have put a Trace method just before the ExecuteScalar() to verify
the sql statement is correct. It always looks just fine. However, in SQL
Profiler, in the BatchStarting Event, the Select statement is corrupt. I
have applied the most recent service pack for MDAC 2.7, reinstalled the .NET
Framework (version 1.1), and deleted and recreated the view all to no avail.
This occurs on 2 of our IIS servers. All other IIS servers we try it on
works fine. This seems to eliminate any bad build problems.

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Neven Klofutar | last post by:
Hi, I have a problem with SqlHelper.ExecuteScalar ... When I try to execute SqlHelper.ExecuteScalar I get this message: "System.InvalidCastException: Object must implement IConvertible.". ...
5
by: bienwell | last post by:
Hi all, I have a problem with using myCommand.ExecuteScalar(). My question is : If the Web setup is incorrect, does it make command ExecuteScalar() work improperly ?? In my program, I was...
3
by: charliewest | last post by:
Hi - I need to detect when the ExecuteScalar() method of the cmd object returns NULL. I have tried the below code, however, it always returns false (this is to say, that ExecuteScalar never...
5
by: djhexx | last post by:
Hello. I have an ASP.NET application (C#) that I allow users to upload files. Files get stored in a SQL2005 database. The file data is stored in a varbinary(max) column. When the user uploads...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.