Click here to Skip to main content
15,885,214 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Dataset containing nullable datetime values does not like a null datetime? Pin
johnsontroye27-Feb-09 9:38
johnsontroye27-Feb-09 9:38 
GeneralRe: Dataset containing nullable datetime values does not like a null datetime? Pin
kriskomar27-Feb-09 9:59
kriskomar27-Feb-09 9:59 
AnswerRe: Dataset containing nullable datetime values does not like a null datetime? Pin
PoweredByOtgc28-Feb-09 5:07
PoweredByOtgc28-Feb-09 5:07 
GeneralRe: Dataset containing nullable datetime values does not like a null datetime? Pin
kriskomar1-Mar-09 6:00
kriskomar1-Mar-09 6:00 
GeneralRe: Dataset containing nullable datetime values does not like a null datetime? Pin
PoweredByOtgc1-Mar-09 6:32
PoweredByOtgc1-Mar-09 6:32 
GeneralRe: Dataset containing nullable datetime values does not like a null datetime? Pin
kriskomar1-Mar-09 14:58
kriskomar1-Mar-09 14:58 
GeneralRe: Dataset containing nullable datetime values does not like a null datetime? Pin
PoweredByOtgc2-Mar-09 13:56
PoweredByOtgc2-Mar-09 13:56 
AnswerPartial fix for control not allowing null value to pass to dataset and database Pin
kriskomar3-Mar-09 6:45
kriskomar3-Mar-09 6:45 
OK, for those poor unfortunate souls who are having this same problem as me, here are the steps I've done so far to remedy:
1) Use the nulldatetimepicker extension shown here: http://www.codeproject.com/KB/selection/NullableDateTimePicker.aspx[^]
and if you're using VB, convert it with this: http://www.developerfusion.com/tools/convert/csharp-to-vb/[^]
2) open the .xsd file of your dataset and manually change the msprop:nullValue="_throw" property of any datetime field to msprop:nullValue="_null". Be aware: every so often the designer will decide to just omit the datetime fields because it's caught on to your treacherous workaround of Microsoft's poor design; and that just cannot be allowed. :P If that happens just go to the designer again and set the fields as (throw exception), save, close, and follow this step again.

This seems to work just fine for existing records. You can re-null datetime fields and successfully update. The only thing I'm having trouble with is inserting new records. I always get:
{"Failed to convert parameter value from a Int32 to a DateTime."}
{"Invalid cast from 'Int32' to 'DateTime'."}
...which is baffling me, but I'm still trying to research, debug, reinvent the wheel for. I'll keep posting as I figure it out.
Here is my entire "add record" sub:
    Private Sub AddBranchToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddBranchToolStripButton.Click

        If PermissionsMode = "ReadWrite" Then
            Dim MainID As String = "0"
            Dim OrgName As String = "Error"

            'Set the OrgRowIsAdding flag to true so that the AutoSave feature doesnt try to save a row with blank data
            OrgRowIsAdding = True

            'record the main loc ID and org name
            MainID = ParentOrgIDTextBox.Text
            OrgName = OrganizationTextBox.Text

            'Actually add the branch
            Try
                If Me.OrganizationsBindingSource.AddNew() IsNot Nothing Then
                    OrganizationTextBox.Text = OrgName
                    ParentOrgIDTextBox.Text = MainID
                    MemberStatusComboBox.SelectedValue = "Branch"
                    MemberTypeComboBox.SelectedValue = "Branch"
                    Me.Text = "[Branch] " & OrgName
                    OrgRowIsAdding = False
                    SetFormControls(True, True)
                Else
                    MsgBox(My.Settings.OrganizationsFrmAddRecGenErrorMsg, MsgBoxStyle.Exclamation, "Error Adding Record")
                    GoTo skipaddbranch
                End If
            Catch ex As Exception
                Throw New Exception("Branch Location Add Failed", ex)
                GoTo skipaddbranch
            End Try
        Else
            MsgBox(My.Settings.StdDenyWriteError, MsgBoxStyle.Exclamation, "Access Denied")
            GoTo skipaddbranch
        End If

skipaddbranch:
        OrgRowIsAdding = False
        Exit Sub

    End Sub


/rant_at_microsoft
Am I just crazy or is it too much to ask of Microsoft to support the SQL datatype in full in their own development application? They wrote SQL 2005, and they wrote Visual Studio 2008.
This problem is driving me nuts. Yeah i know, i know...most people claim it has something to do with SQL/Visual Studio versions not being exactly on par, but really I've found posts on this same topic concerning VS 2005!!! So personally, I don't buy it. Additionally, you've been able to null datetime fields in SQL for a while now, so to me this is just plain old negligence on Microsoft's part. Get it together Microsoft!
/endrant
/rant_at_everyone
Am I to understand that every single programmer that uses Visual Studio simply accepts the workaround to use date.mindate as a replacement for null???? I guess I just can't accept that. I'm determined to figure this out.
/endrant_at_everyone
More to come....
AnswerRe: Dataset containing nullable datetime values does not like a null datetime? Pin
kriskomar4-Mar-09 7:05
kriskomar4-Mar-09 7:05 
GeneralRe: Dataset containing nullable datetime values does not like a null datetime? Pin
kriskomar5-Mar-09 4:58
kriskomar5-Mar-09 4:58 
Questionhow to do the custom installation of vb.net windows applications project ? [modified] Pin
pramod251727-Feb-09 2:08
pramod251727-Feb-09 2:08 
AnswerRe: how to do the custom installation of vb.net windows applications project ? Pin
Eddy Vluggen27-Feb-09 2:34
professionalEddy Vluggen27-Feb-09 2:34 
AnswerRe: how to do the custom installation of vb.net windows applications project ? Pin
Jon_Boy27-Feb-09 2:43
Jon_Boy27-Feb-09 2:43 
QuestionVB.Net and C# and VC++ in single project Pin
Samir Ibrahim26-Feb-09 23:35
Samir Ibrahim26-Feb-09 23:35 
AnswerRe: VB.Net and C# and VC++ in single project Pin
Smithers-Jones27-Feb-09 0:13
Smithers-Jones27-Feb-09 0:13 
AnswerRe: VB.Net and C# and VC++ in single project Pin
Jon_Boy27-Feb-09 2:38
Jon_Boy27-Feb-09 2:38 
AnswerRe: VB.Net and C# and VC++ in single project Pin
Dave Kreskowiak27-Feb-09 7:52
mveDave Kreskowiak27-Feb-09 7:52 
QuestionHow to send E-Mail from VB.Net from [modified] Pin
palathoti26-Feb-09 21:56
palathoti26-Feb-09 21:56 
AnswerRe: How to send E-Mail from VB.Net from Pin
Eddy Vluggen26-Feb-09 22:38
professionalEddy Vluggen26-Feb-09 22:38 
GeneralRe: How to send E-Mail from VB.Net from Pin
palathoti26-Feb-09 23:40
palathoti26-Feb-09 23:40 
Questionread from ini file Pin
dec8226-Feb-09 21:32
dec8226-Feb-09 21:32 
AnswerRe: read from ini file Pin
Eddy Vluggen26-Feb-09 22:40
professionalEddy Vluggen26-Feb-09 22:40 
QuestionGet the all selected value of listbox window project in vb.net Pin
Jagz W26-Feb-09 20:28
professionalJagz W26-Feb-09 20:28 
AnswerRe: Get the all selected value of listbox window project in vb.net [modified] Pin
Eddy Vluggen26-Feb-09 21:49
professionalEddy Vluggen26-Feb-09 21:49 
GeneralRe: Get the all selected value of listbox window project in vb.net Pin
Jagz W26-Feb-09 23:27
professionalJagz W26-Feb-09 23:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.