Ask a Question related to ASP.NET General, Design and Development.
-
Edward #1
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
Edward Guest
-
Adding Identity Tag Caused Error
Hello I'm trying to play with impersonation. I added an identity tag both with and without the userName/password attributes and I get this error on... -
PDF files from Illustrator caused an Error
I created a PDF file directly from Illustrator CS (using Save As command). When I try to open the file in a Internet Explorer 6.0 by clicking the... -
#24791 [Com]: Strange error caused by missing DLL
ID: 24791 Comment by: Nico dot Laus dot 2001 at gmx dot de Reported By: svanleent at wanadoo dot nl Status: ... -
Error Expected ';' in .Net Framework
This is a javascript error. If you had looked at the source, you would have seen, that your form's name is _ctl1:Form. ..NET creates a... -
.Net Framework, error 11606
hi, my .Net Framework was installed when I had windows ME on my computer, the pack was downloaded from windows update, now, after updating to... -
Cowboy \(Gregory A. Beamer\) #2
Re: SQL Error caused by .NET Framework incompatibility
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" <teddysnips@hotmail.com> wrote in message
news:25080b60.0307180622.4edf66b9@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
Cowboy \(Gregory A. Beamer\) Guest



Reply With Quote

