Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 13th, 2004, 08:07 AM
Registered User
 
Join Date: Oct 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to remove "null" in the datagrid.

Hi,
   I was entering the data in the datagrid, when i noticed that when we want to add a new row we get a empty row with text as "null". How can we remove that "null".
Can anyone help me.

Thanks.
With Regards,
Arun.
 
Old October 13th, 2004, 09:05 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

What you may want to do is apply a default to that column.

see default in Books Online

Defaults
Defaults specify what values are used in a column if you do not specify a value for the column when inserting a row. Defaults can be anything that evaluates to a constant, such as:

Constant


Built-in function


Mathematical expression
There are two ways to apply defaults:

Create a default definition using the DEFAULT keyword in CREATE TABLE to assign a constant expression as a default on a column.
This is the preferred, standard method. It is also the more concise way to specify a default.

Create a default object using the CREATE DEFAULT statement and bind it to columns using the sp_bindefault system stored procedure.
This is a backward compatibility feature.

This example creates a table using one of each type of default. It creates a default object to assign a default to one column, and binds the default object to the column. It then does a test insert without specifying values for the columns with defaults and retrieves the test row to verify the defaults were applied.

USE pubs
GO
CREATE TABLE test_defaults
   (keycol smallint,
   process_id smallint DEFAULT @@SPID, --Preferred default definition
   date_ins datetime DEFAULT getdate(), --Preferred default definition
   mathcol smallint DEFAULT 10 * 2, --Preferred default definition
   char1 char(3),
   char2 char(3) DEFAULT 'xyz') --Preferred default definition
GO
/* Illustration only, use DEFAULT definitions instead.*/
CREATE DEFAULT abc_const AS 'abc'
GO
sp_bindefault abc_const, 'test_defaults.char1'
GO
INSERT INTO test_defaults(keycol) VALUES (1)
GO
SELECT * FROM test_defaults
GO

The output of this sample is:

Default bound to column.

(1 row(s) affected)

keycol process_id date_ins mathcol char1 char2
------ ---------- --------------------------- ------- ----- -----
1 7 Oct 16 1997 8:34PM 20 abc xyz



Jaime E. Maccou
Applications Analyst
 
Old October 20th, 2004, 12:30 AM
Authorized User
 
Join Date: Oct 2004
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

try this

objTable.Columns("Fields").DefaultValue = String.Empty






Similar Threads
Thread Thread Starter Forum Replies Last Post
All fields of datagrid are Null hexOffender VB Databases Basics 0 March 23rd, 2006 02:22 PM
How to set Not Null constraint to Null Columns arasu Oracle 1 August 22nd, 2005 10:09 AM
How to remove row from datagrid iniro VB.NET 2002/2003 Basics 3 November 10th, 2004 09:28 AM
How to remove ? abdusalam Javascript How-To 1 July 27th, 2004 01:24 AM
How REMOVE NULL in DATA GRID kfls_83 SQL Server 2000 1 April 19th, 2004 10:01 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.