Results 1 to 6 of 6

Thread: Strange Error

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026

    Strange Error

    Why would this:

    MyBase.ShowDialog()


    Produce this error:

    Object reference not set to an instance of an object.


    ???

    Squirrelly1
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026
    And it only happens when I execute the following code:

    VB Code:
    1. If Not LCase(txtPassword.Text) = LCase(txtConfirm.Text) Then Exit Sub
    2.  
    3.         Dim Changed As Boolean = False
    4.  
    5.         Dim Conn As New OleDbConnection(ConnectionString)
    6.         Dim Cmd As OleDbCommand = Conn.CreateCommand
    7.         Cmd.CommandText = "SELECT UserName, Password FROM Users"
    8.         Conn.Open()
    9.         Dim DA As New OleDbDataAdapter
    10.         DA.SelectCommand = Cmd
    11.         Dim DS As New DataSet
    12.         DA.Fill(DS, "Users")
    13.  
    14.         Dim NewRow As DataRow
    15.         NewRow!UserName = txtUserName.Text
    16.         NewRow!Password = txtPassword.Text
    17.         DS.Tables("Users").Rows.Add(NewRow)
    18.  
    19.         Dim CB As New OleDbCommandBuilder(DA)
    20.         DA.UpdateCommand = CB.GetUpdateCommand
    21.         DA.Update(DS, "Users")
    22.  
    23.         MsgBox("Added New User!", MsgBoxStyle.OKOnly, "Success")
    24.         Me.DialogResult = DialogResult.OK
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026
    missed one more thing..

    If I just do:

    Me.DialogResult = DialogResult.OK

    by itself in a button I have no problem

    Squirrelly1
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

  4. #4
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Hi,

    I'm probably missing the point entirely but I thought you used MyBase to refer to methods in the base class which you have overridden in the instanced version but want to access. So, why would you expect to be able to show the base form when you have not created an instance of it? (The instance from which you are doing the calling does not count)
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    VB Code:
    1. Me.DialogResult = DialogResult.OK

    What are you doing this for?

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026
    I did that so it would return from the dialogbox back to the calling form.


    The problem is not with MyBase afterall... it is with the code I tried to implement to add a new record to my database... it's screwed up

    squirrelly1
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width