Wrox Programmer Forums
|
Visual Studio 2008 For discussing Visual Studio 2008. Please post code questions about a specific language (C#, VB, ASP.NET, etc) in the correct language forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Studio 2008 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 2nd, 2009, 08:34 AM
Registered User
 
Join Date: Apr 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with dataset

hi i've only being studying programming for a year and a half in college so please excuse any stupid questions lol. at college i've been doing a project on vb.net 2005 but at home i have 2008. at college this code works but at home it doesnt i cant work it out.

Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Call Openuserdatabase()

        SQL = "SELECT * FROM tblUserInformation"

        da = New OleDb.OleDbDataAdapter(Sql, con2)

        da.Fill(ds, "Users")
    End Sub

    Private Sub btnLogIn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogIn.Click
        Do While iCount <= (ds.Tables("Users").Rows.Count) - 1
            If txtUsername.Text = ds.Tables("Users").Rows(iCount).Item(4) _
            Then
                If txtPassword.Text = ds.Tables("Users").Rows(iCount).Item(5) _
                Then
                    UserRow = iCount
                    frmSelect.Show()
                    Me.Close()
                    Exit Do
                Else
                    MsgBox("Please enter correct password")
                    intLoginCheck = intLoginCheck + 1
                    txtPassword.SelectAll()
                    txtPassword.Focus()
                    Exit Do
                End If
            Else
                iCount = iCount + 1
                If iCount = (ds.Tables("Users").Rows.Count) _
                Then
                    MsgBox("User not found")
                    txtUsername.Text = ""
                    txtUsername.Focus()
                    txtPassword.Text = ""
                    Exit Sub
                End If
            End If
        Loop
It keeps coming back with NullReferenceException was unhandled - object reference not set to an instance of an object. the coding for the connection is in a module and should produce a message box saying the connection is ok after it connects but no message box appears before the first form loads like it does at college. hers the code for the connection:

Code:
Public con As New OleDb.OleDbConnection
    Public con2 As New OleDb.OleDbConnection
    Public da As OleDb.OleDbDataAdapter
    Public ds As New DataSet
    Public ds2 As New DataSet
    Public ds3 As New DataSet
    Public UserRow As Integer

    Public iCount As Integer

    Public Sub Opendatabase()
        con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = F:\Rhys Crap\tblCriminal.mdb"

        con.Open()
        MsgBox("Connection OK")
    End Sub
    Public Sub Closedatabase()

        con.Close()
        MsgBox("Connection Closed")
    End Sub
    Public Sub Openuserdatabase()
        con2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = F:\Rhys Crap\tblUsers.mdb"

        con2.Open()
        MsgBox("Connection OK")
    End Sub
the path for the connection is right so i can't work out what is wrong and i need this to work so i can test the rest of my project. please help me

(edit) ok so i've just downloaded 2005 but it still wont work on that. could it be that my system is running on 64bit?

Last edited by coolslayerlies; April 2nd, 2009 at 09:22 AM..
 
Old April 2nd, 2009, 11:17 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hello..

Did you trace your code to find out what object is failling?? (or at least where it fails??)

Also, do you have your database in this paht = F:\Rhys Crap\tblCriminal.mdb???
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old April 2nd, 2009, 11:23 AM
Registered User
 
Join Date: Apr 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

the path is right and im sorry i forgot to put that the error came up with
Code:
Do While iCount <= (ds.Tables("Users").Rows.Count) - 1
and i think the problem must lie with the connection because the msgbox doesn't appear before the form loads like it did at college
 
Old April 2nd, 2009, 11:33 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

The problem is that is never go through the load procedure...

You don't have any error in your code?? no line marked red anywhere???

What happens if you doubleclick on your form?? it goes to the load procedure or to another part?? If you set a breakpoint in the load form do you see the code stopping there??
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old April 2nd, 2009, 11:55 AM
Registered User
 
Join Date: Apr 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

no no errors in the code, like i said it works perfectly well at college. if i double click on the form it goes to form load and i set a breakpoint and it goes to the procedure on loading, but the code stops on opening the connection, it never goes to the msgbox or to the sql on the form load





Similar Threads
Thread Thread Starter Forum Replies Last Post
DataSet problem HelpWanted ASP.NET 1.0 and 1.1 Basics 3 November 15th, 2006 02:28 AM
Dataset Problem monika.vasvani ASP.NET 1.0 and 1.1 Professional 1 September 26th, 2006 10:04 AM
DataSet Example Problem sfx BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 0 February 14th, 2006 01:16 AM
problem in updating in dataset vohra_vikas2004 ADO.NET 1 June 28th, 2005 05:26 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.