Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Delete value in datetime field using Visual Basic

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-03-19 : 11:24:06
D. Johnsson writes "Hi,

I´m using Microsoft SQL Server 7.0 and Visual Basic 6.0 Ent ed.

I have a datetime-field, and have entered a date. After that I can change the date to any other (valid) date, but I can not remove the date (make the field empty again).

In SQL Server Enterprise manager, I can use Ctrl + 0 (zero) to empty the field and insert a Null again, but I want to do it in Visual Basic.

I use the ADO control to connect to the SQL Server.


I hope you can help me with this problem,

With Kind regards,

D. Johnsson
dajo@ljunghall.se"

Jay99

468 Posts

Posted - 2002-03-19 : 12:34:20
This is a sql server forum, so you are going to get sql server answers.

You should ... UPDATE blah set blah = null where blah

Now, I think I understand that this is a VB app and you may not want to go back to the database just clear out a field in the gui. You may get a vb answer here, but you best bet is going to be to seek out a vb resource . . .

Jay
<O>
Go to Top of Page

yakoo
Constraint Violating Yak Guru

312 Posts

Posted - 2002-03-19 : 16:38:24
Really depends what you are doing.

If you are using ADO to execute a stored procedure then you want the stored procedure to execute the update statment "UPDATE table SET DateCol = NULL"

otherwise in VB you can use ADO's Connection object to execute that same T-SQL Statment


Set Conn = New ADODB.Connection
Conn.Open strConnection

Conn.Execute "UPDATE table SET DateCol = NULL"

Conn.Close
Set Conn = Nothing


Go to Top of Page

simondeutsch
Aged Yak Warrior

547 Posts

Posted - 2002-03-20 : 00:19:37
If you are using a field (Textbox) bound to the ADO Data Control, there is no way to get that null again unless you code an IIF that reassigns the field in an event like WillMove, e.g. rs!date = IIF(isdate(txtdate.text) = false,NULL,txtdate.text).

Sarah Berger MCSD
Go to Top of Page
   

- Advertisement -