Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I write out a record to an SQL database table? 1

Status
Not open for further replies.

furjaw

Programmer
Mar 27, 2006
49
US
Visual Basic 2005 Express Edition:

I am trying to write out a record to an SQL database table:

Private Sub WriteOutRx()

Me.RxBindingSource.Current("PatientLastName") = PatientLastName <---Error on this line

Me.Validate()

Me.RxTableAdapter.Update(Me.RxDataSet.Rx)

End Sub

Below is the error message that I got:

NullReferenceException was Unhandled

Object variable or With block variable not set.

use the 'new' keyword to create an object instance.



 
The first thing that jumps out is the variable "PatientLastName" doesn't seem to be declared anywhere. In order for it to know what to put in there, you would need to either have PatientLastName declared globally (not recommended) or have a method level reference to it. You can do this by passing the text box value directly(not recommended either) or passing the value to the procedure.

You also need to make sure that RxBindingSource is valide in your procedure. Typically you would declare it in the procedure, but it may be declared at the class level.

Also, a trick that you can do is to create a breakpoint on that line and when it hits it will pause processing. You can then hover your cursor over the variable and see exactly what's being passed to it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top