devxlogo

Access Data From SQL Server in ASP

Access Data From SQL Server in ASP

Question:

I’m using Microsoft SQL Server 6.5, Active Server Pages (ASP), and ActiveX Data Objects (ADO). When I retrieve a string with a value of “New York” from the table and assign the value to a text box, I get only “New” and nothing after the space. For example:

strcity = recordset("city")

I define the input box as:

VALUE=

Also, how can I assign a null value to an integer type column? For example, in Sybase you use the setnull() to set the value of a variable to null when inserting a row in the table.

Answer:

There is a problem in your HTML code. For the text box, instead of using:

VALUE=

use:

VALUE=""   

The double quotes will make sure the entire contents of the variable strCity becomes the ‘value’ of the text box.

To assign a null value to an integer type column, use the keyword Null. For example:

UPDATE TABLENAME SET FIELDNAME = NULL

or

INSERT INTO TABLENAME (FIELDNAME) VALUES Null

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist