Under normal circumstances I am not TOO bad at trying to figure errors out. However, I can't seem to understand why I am getting the age ol' "Object reference not set to an instance of an object error" in this lil bit of code.
This is where I define my 'intTotalRecords'
However, I am getting the error here where I am attempting to set the value of intCount to the value that is held in total records + 1. The above block of code runs first to get the count of records. It may return 0 if no records exist and THAT I understand but I am not understanding the object reference in this instance!!!Code:Connection.Open() Command.CommandText = "SELECT * FROM CompanyTable" Command.Connection = Connection DAdapter.SelectCommand = Command DAdapter.Fill(Dset, "MyTable") intTotalRecords = Dset.Tables("MyTable").Rows.Count Connection.Close()
Hope everyone is looking forward to a Merry Christmas.Code:intCount = intTotalRecords + 1 CompRec(intCount).CompID = intCount CompRec(intCount).Street = frmNew.txtStreet.Text CompRec(intCount).Phone = CInt(frmNew.txtPhone.Text) CompRec(intCount).AccntNum = frmNew.txtAccntNum.Text CompRec(intCount).Balance = CDec(frmNew.txtCurrBal.Text) CompRec(intCount).DateDue = CDate(frmNew.txtDateDue.Text) CompRec(intCount).WebUrl = frmNew.txtUrl.Text CompRec(intCount).State = frmNew.txtState.Text CompRec(intCount).Zip = CInt(frmNew.txtZip.Text) CompRec(intCount).CompName = frmNew.txtCompName.Text






Reply With Quote