hello experts..please help me..How can i solve this error...

       Using db As New DB_CARRENTALEntities1
        Dim x
        Dim a = db.tbl_customer.Where(Function(b) b.cardesc = "studnum").FirstOrDefault
        x = a.CustomerID + 1<<<<<(Object reference not set to an instance of an object.) how can i solve this error..

        Dim newstudnum As String = "104-" & Format(Now, "yyyy") & "-" & Format(x, "000#")
        TextBox1.Text = newstudnum

        Dim d = db.tbl_customer.Where(Function(f) f.cardesc = "studnum").FirstOrDefault
        Dim y As Integer

        y = x
        d.CustomerID = y


        db.SaveChanges()
        db.AcceptAllChanges()

        cmdID.Enabled = False
    End Using

Recommended Answers

All 2 Replies

What error is being thrown?

variable "a" seems to be null, or has no value at all.

commented: Good catch. +0
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.