Hey Guys,
I am trying to create a little project for my college course.
I have been trying in vain over the past few days to sort out some errors i have and alot of google pages have brought me here where i have gained alot of knowledge so i thought it would be best to come here and get some advice.

right, my problems...

firstly, i will say from the off that one of the specifications of my course is that i dont use DATAGRID's. i know its a pain but unfortunately it has to be done :(

i have a form which inputs data into a database which isnt working.

here is the code:

rownumber = 0

        dbProvider = "Provider = Microsoft.ACE.OLEDB.12.0;"
        dbSource = "Data Source = G:\Users\Ross\Desktop\EXTENDED PROJECT !!!!!!\Databases\Login Details.accdb"

        loginconnection.ConnectionString = dbProvider & dbSource
        loginconnection.Open()

        If rownumber <> -1 Then
            Dim sqlquerydetails = "SELECT * FROM CustomerDetails"

            Dim dsinputNewRow As DataRow

            'dainput = New OleDb.OleDbDataAdapter(sqlquerydetails, loginconnection)    RESULTS IN DAINPUT NULL REFERENCE POINT

            dainput = New OleDb.OleDbDataAdapter(sqlquerydetails, loginconnection)

            Dim cbinput As New OleDb.OleDbCommandBuilder(dainput)


            dsinputNewRow = dsinput.Tables("CustomerDetails").NewRow()

            dsinputNewRow.Item("Surname") = surname
            dsinputNewRow.Item("FirstName") = firstname
            dsinputNewRow.Item("Address1") = address1
            dsinputNewRow.Item("DOB") = dob
            dsinputNewRow.Item("CarMake") = carmake
            dsinputNewRow.Item("PostCode") = postcode
            dsinputNewRow.Item("HouseNumber") = houseno
            dsinputNewRow.Item("ContactNumber1") = contact1
            dsinputNewRow.Item("ContactNumber2") = contact2
            dsinputNewRow.Item("BorrowingAmmount") = borrowing
            dsinputNewRow.Item("YearlyIncome") = yearlyin
            dsinputNewRow.Item("CreditRating") = credit
            dsinputNewRow.Item("Deposit") = deposit
            dsinputNewRow.Item("Price") = price
            dsinputNewRow.Item("Employed") = employed
            dsinputNewRow.Item("CarModel") = carmodel


            dsinput.Tables("CustomerDetails").Rows.Add(dsinputNewRow)
            dainput.Update(dsinput, "CustomerDetails")
            MsgBox("New Record added to the Database")
        End If

Now it is throwing up and error on the line:

dsinputNewRow = dsinput.Tables("CustomerDetails").NewRow()

it says: "Object reference not set to an instance of an object"

i have no idea what this means...

any ideas will be much appreciated.


Regards

Ross

Recommended Answers

All 2 Replies

it seems to be showing null Exception from database field.

how would i fix that though?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.