insert <NULL>

jutiyi

Member
Joined
Feb 16, 2005
Messages
14
Programming Experience
1-3
i know that in order to insert <NULL> to the database field of sql server, need to key in ctrl+0 in the sql server software inself.

But,

How to use vb.net programming code to insert <NULL> to the datetime type column of sql server database?


Thanks.
 

ritesh_jain1982

Well-known member
Joined
Jan 10, 2005
Messages
53
Programming Experience
1-3
Hi,
if you are using sqlparameter to pass the value than just use

Dim sqlParameter As SqlParameter

sqlParameter =
New SqlParameter("@Date", DBNull.Value)

Or if ur directly using query u can use.........

Dim strInsert As String = "INSERT INTO Customer(CustomerIndex,CutomerCode,CustomerName,DateOfBirth) VALUES(1,'CUST1','Test',NULL)"

Dim conSQL As New SqlConnection(pi_strCON)

Dim comSQL As New SqlCommand(strInsert, conSQL)

conSQL.Open()

comSQL.ExecuteNonQuery()

conSQL.Close()


I hope this will help u..............

Regards,
Ritesh
 
Top Bottom