473,466 Members | 1,397 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

SQL Error caused by .NET Framework incompatibility

Our app was built on VS using .NET Framework version 1.0.3705 It
worked fine until last week when the SysAdmin installed W2k SP4 which,
it appears, installs the .NET Framework version 1.1 This has broken
our code. It was failing with the error :

"Syntax error converting from a character string to uniqueidentifier."

The SQL in question was, in retrospect, probably not very well formed:

"SELECT tblContacts.*, tblCompanies.fldCompanyName FROM tblContacts
INNER JOIN tblCompanies ON tblContacts.fldCompanyID =
tblCompanies.fldCompanyId WHERE (fldContactID = '" & CType(pRecordID,
String) & "')"

If the value of pRecordID was empty, the actual SQL was

"SELECT tblContacts.*, tblCompanies.fldCompanyName FROM tblContacts
INNER JOIN tblCompanies ON tblContacts.fldCompanyID =
tblCompanies.fldCompanyId WHERE (fldContactID = '')"
The function that used this SQL was:

Public Overloads Shared Function ExecuteReader(ByVal connectionString
As String, ByVal commandType As CommandType, ByVal commandText As
String) As SqlDataReader

In the previous (working) version this simply returned Nothing which
was fine - we would test for Nothing, and deduce that this meant a new
record.

Under the new version of .NET Framework, this throws the above error.

Just a heads up if you are interested. We were under the impression
that Visual Studio targetted particular Frameworks, and that versions
1.0.3705 and 1.1 were designed to sit together side by side. Seems
not.

Best

Edward
Nov 17 '05 #1
1 1691
My suggestion is this. Alter the statement to something like:

Dim sql As String = "SELECT tblContacts.*, tblCompanies.fldCompanyName FROM
tblContacts
INNER JOIN tblCompanies ON tblContacts.fldCompanyID =
tblCompanies.fldCompanyId WHERE (fldContactID = @fldContactID)"

Then, set up a parameter for @fldContactID using a SQLGuid (assuming this is
a uniqueIdentifier from the error message):

Imports System.Data.SqlTypes

....

Dim sg As SqlGuid

Try
sg = new SqlGuid(pRecordId)
Catch
If pRecordId.Trim() = "" Then
sg = SqlGuid.Null
Else
'You figure how to handle garbage here
End If
End Try

'Set up param
cmd.Parameters.Add("@fldContactId", sg)

You now can properly handle a NULL rather than have the Framework cast an
empty as a NULL.

Hope this helps.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
Author: ADO.NET and XML: ASP.NET on the Edge

************************************************** **************************
****
Think Outside the Box!
************************************************** **************************
****
"Edward" <te********@hotmail.com> wrote in message
news:25**************************@posting.google.c om...
Our app was built on VS using .NET Framework version 1.0.3705 It
worked fine until last week when the SysAdmin installed W2k SP4 which,
it appears, installs the .NET Framework version 1.1 This has broken
our code. It was failing with the error :

"Syntax error converting from a character string to uniqueidentifier."

The SQL in question was, in retrospect, probably not very well formed:

"SELECT tblContacts.*, tblCompanies.fldCompanyName FROM tblContacts
INNER JOIN tblCompanies ON tblContacts.fldCompanyID =
tblCompanies.fldCompanyId WHERE (fldContactID = '" & CType(pRecordID,
String) & "')"

If the value of pRecordID was empty, the actual SQL was

"SELECT tblContacts.*, tblCompanies.fldCompanyName FROM tblContacts
INNER JOIN tblCompanies ON tblContacts.fldCompanyID =
tblCompanies.fldCompanyId WHERE (fldContactID = '')"
The function that used this SQL was:

Public Overloads Shared Function ExecuteReader(ByVal connectionString
As String, ByVal commandType As CommandType, ByVal commandText As
String) As SqlDataReader

In the previous (working) version this simply returned Nothing which
was fine - we would test for Nothing, and deduce that this meant a new
record.

Under the new version of .NET Framework, this throws the above error.

Just a heads up if you are interested. We were under the impression
that Visual Studio targetted particular Frameworks, and that versions
1.0.3705 and 1.1 were designed to sit together side by side. Seems
not.

Best

Edward

Nov 17 '05 #2

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

Similar topics

5
by: Fahad Ashfaque | last post by:
qaHi, I am trying to assign value to a member of object of a struct, the object is treated under foreach. I got the error : error CS0170: Use of possibly unassigned field 'price' according...
8
by: Rod | last post by:
I have been working with ASP.NET 1.1 for quite a while now. For some reason, opening some ASP.NET applications we wrote is producing the following error message: "The Web server reported...
1
by: ~~~ .NET Ed ~~~ | last post by:
I tried to create an ASP.NET web project on my machine and this is what I did: System: WinXP Professional SP1 FS: NTFS Visual Studio .NET 2003 Framework 1.1 IIS Installed 1. I (Developer)...
9
by: Tim D | last post by:
Hi, I originally posted this as a reply to a rather old thread in dotnet.framework.general and didn't get any response. I thought it might be more relevant here; anyone got any ideas? My...
10
by: Shawn | last post by:
JIT Debugging failed with the following error: Access is denied. JIT Debugging was initiated by the following account 'PLISKEN\ASPNET' I get this messag in a dialog window when I try to open an...
1
by: Dan | last post by:
Hi everyone, I have a web application that was built in .net. I received the source code and the DLL files, compiled the application, and when I run it on IIS, I get the following error. ...
7
by: deltalimagolf | last post by:
I now get the following error message after copying an asp.net application to the deployment web server. I don't have SQLExpress or any version of SQL 2005 installed. I found the "LocalSQLServer"...
13
by: Kevin Liebowicz | last post by:
Yes, I wasted the past two days trying to fix this. Yes, this is on a Win2003 Server. Yes, this machine is a domain controller. Yes, I seen the dozens of KB articles like this one:...
0
by: aboutjav.com | last post by:
Hi, I need some help. I am getting this error after I complete the asp.net register control and click on the continue button. It crashed when it tries to get it calls this Profile property ...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.