Groups | Blog | Home
all groups > sql server programming > january 2004 >

sql server programming : SQL Server ASP returns null


William Morris
1/14/2004 4:28:05 PM
Not enough info. What's the structure of the table? What's the code making
the query? How are you doing the output?

[quoted text, click to view]

Tim Gaunt
1/14/2004 10:25:26 PM
Hi,

I'm new to SQL Server and have encountered an interesting problem and was
wondering whether there were any solutions.

Basically I retreive records from the SQL Server and populate a form which
the user filled in earlier however, although there is data stored in the
fields, it returns null for certain fields namely:

KDLDesignation
CSSDesignation
anything starting with EC_ or MC_

I don't think they're reserved words and I'm flumoxed, any ideas?

Cheers.

Tim

Tim Gaunt
1/17/2004 6:45:33 AM
I'm using a standard recordset in the format:

<%
Dim ConAss
Dim ConAss_numRows

Set ConAss = Server.CreateObject("ADODB.Recordset")
ConAss.ActiveConnection = MM_Delay_STRING
ConAss.Source = "SELECT * FROM dbo.ContactAssesment WHERE CFNID = " +
Replace(ConAss__MMColParam, "'", "''") + ""
ConAss.CursorType = 0
ConAss.CursorLocation = 2
ConAss.LockType = 1
ConAss.Open()

ConAss_numRows = 0
%>

To retreive the field values:

<%=(ConAss.Fields.Item("EC_Forename").Value)%>

As mentioned in my previous post, all the other fields are coming
through with the correct data in, its just the fields:

KDLDesignation
CSSDesignation
anything starting with EC_ or MC_

that are being retrieved with null values. I hope thats enough info to
work out whats wrong, if not let me know.

Tim

*** Sent via Developersdex http://www.developersdex.com ***
William Morris
1/19/2004 10:07:46 AM
Looks good to me. Try taking your query and putting into a string variable
first, then response.write it. What happens when you run that query in
Query Analyzer? Have you verified that the values truly aren't null for the
*exact* query being run?

[quoted text, click to view]

William Morris
1/20/2004 3:12:18 PM
Try this:

dim strVar
'--- just in case: the plus sign is not a valid concantenation operator.
Use &.
strVar = "SELECT * FROM dbo.ContactAssesment WHERE CFNID = " _
& Replace(ConAss__MMColParam, "'", "''")

response.write strVar

ConAss.Source = strVar


[quoted text, click to view]

Tim Gaunt
1/20/2004 8:58:33 PM
Sorry but I'm being rather thick, how should I put it in a string variable
and how should I analyse the query?

Sorry if its obvious but I'm very tired and I'm not thinking straight.

Cheers.

Tim


"William Morris" <news.remove.this.and.the.dots@seamlyne.com> wrote in
message news:bugvd9$hsila$1@ID-205671.news.uni-berlin.de...
[quoted text, click to view]

Tim Gaunt
1/21/2004 5:35:37 AM
lol thats what I thought you meant! Sadly this produces the result as
expected:

"SELECT * FROM dbo.ContactAssesment WHERE CFNID = 1"

I've even tried hard coding the CFNID instead of using "+
Replace(ConAss__MMColParam, "'", "''") +"

As before all expect a few of the feilds come through fine but as
before, the fields:
KDLDesignation, CSSDesignation and anything starting with EC_ or MC_ are
still being populated as null.

When running the query through the Query analyser, it produces the
expected results and even populates KDLDesignation, CSSDesignation and
anything starting with EC_ or MC_.

Any more ideas?

*** Sent via Developersdex http://www.developersdex.com ***
AddThis Social Bookmark Button