setting a dataset date value to null

G

Guest

Hello,
I wish to set a date in a datarow to dbNull. the column fixeddate does allow nulls in the
dataset

Whenever I try and set the value to dbNull or "" I get an invalid cast error, is there any way tha
I can get

Dim drCurrentProj as dataro

Call MyDataAccess.LoadDataset(GblConnectionString2, mysqladapter, Mydataset, strquery, "Project"
DrCurrentProj = Mydataset.Tables("Project").Rows.Find(IntProjectId

Dim strFixedDate As String = MyForm.dtpFixedDate.Tex

If Not IsDBNull(strFixedDate) And strFixedDate <> "01 January 0001" And strFixedDate <> "" The
DrCurrentProj("FixedDate") = CDate(strFixedDate
ElseIf strFixedDate = "" The
DrCurrentProj("FixedDate") = DBNul
End I

Any ideas on how this seemingly simple task could be achieve

The datetimepicker that I'm using is a speciall datetimepicker called datetimeslicker that blanks out the field if you uncheck the checkbox

any help would be greatly appreciated
David
 
C

Cor Ligthert

Hi David,

One of the things to archieve this is to set Option Strict On in top of your
program.
Than you will see that DBNull does not work however has to be dbNull.Value

I hope this helps?

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top