Link to home
Start Free TrialLog in
Avatar of victornegri
victornegri

asked on

ASP SQL Query not displaying all the data

I used Dreamweaver to create a SQL query. For some reason, the query displays some columns but not others. I can't figure out why. For example with the below code, it displays everything except for "Summary" and "Body". If I copy the "Attachment" and "Image" Response.Write lines below "Body" and "Summary", it displays all data except for "Attachment".
Dim recordset__MMColParam
recordset__MMColParam = "1"
If (Request.QueryString("id") <> "") Then 
  recordset__MMColParam = Request.QueryString("id")
End If
 
Dim recordset
Dim recordset_cmd
Dim recordset_numRows
 
Set recordset_cmd = Server.CreateObject ("ADODB.Command")
recordset_cmd.ActiveConnection = MM_kustream_STRING
recordset_cmd.CommandText = "SELECT * FROM dbo.tNews WHERE id = ?" 
recordset_cmd.CommandType = 1
recordset_cmd.Prepared = true
recordset_cmd.Parameters.Append recordset_cmd.CreateParameter("param1", 3, 1, -1, recordset__MMColParam) ' adDouble
 
Set recordset = recordset_cmd.Execute
recordset_numRows = 0
 
 
Response.Write("id= " & recordset.Fields.Item("id").Value)
Response.Write("Title= " & recordset.Fields.Item("title").Value)
Response.Write("SubTitle= " & recordset.Fields.Item("subtitle").Value)
Response.Write("Attachment= " & recordset.Fields.Item("attachment").Value)
Response.Write("Image= " & recordset.Fields.Item("imageName").Value)
Response.Write("Body= " & recordset.Fields.Item("body").Value)
Response.Write("Summary= " & recordset.Fields.Item("summary").Value)

Open in new window

Avatar of souvik2008
souvik2008
Flag of India image

I would love to know the database schema of table dbo.tNews. And check for the spelling of the body and the summary there. Also check the datatype of these fields. Otherwise for now your code seems fine to me.
Avatar of victornegri
victornegri

ASKER

Everything is spelled correctly. I even deleted all the Response.Write lines and re-created them and it does the same thing. I've also manually typed in test data (i.e. "Test Title", "Test Attachment", "Test Body") into each field so I eliminated the possibility that it's some weird SQL injection type code that's messing up my query.

Using SQL 2005 Express on Windows 2003 Server.

Have attached the SQL Create script for that table so you can see the structure.

Keep in mind that the body and summary data displays if I move the line for "attachment" below them so it's not a problem with the lines to display summary and body, it's something to do with getting the data from the server.

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[tNews](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[title] [nvarchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[subtitle] [nvarchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[body] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[attachment] [nvarchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[summary] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[imageName] [nvarchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
 CONSTRAINT [PK_tNews] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Wayne Barron
Wayne Barron
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That worked! Thanks
anytime.
Have a good one
Carrzkiss