Cant solve this error.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi Folks

I keep recieving the following error message when i try to bind a combobox to the value that is in a textbox. the application crashes on the following line...

Me.CBoxTitle.SelectedItem = frmExistingCustomer.TBTitle.Tex

this is the error mesaage i recieve
An unhandled exception of type 'System.NullReferenceException' occurred in Caravan.ex
Additional information: Object reference not set to an instance of an object

any help is appreciated
 
Can't really say exactly what is wrong, but judging from the error message,
an object hasn't yet been instantiated. Now, in which method are you trying
to do this? Perhaps you're trying to perform this assignment before the
CBoxTitle has been instantiated (such as in the Page_Init event procedure),
or perhaps the frmExistingCustomer isn't loaded?
 
Hi

The error i now recieve is

Cant bind to property or coloumn Title on datacource. Parameter name: datamembe

this message appears when i click the OK button on Form2. The message does not end the application but my binding code does not run
Here is my binding code

Tr
cn.Open(

da.Fill(Guest.dsGuest, "ClientDet"

txtTitle.DataBindings.Clear(
txtForename.DataBindings.Clear(
txtSurname.DataBindings.Clear(
txtaddress.DataBindings.Clear(
txtPostcode.DataBindings.Clear(
txtorganisation.DataBindings.Clear(
txtPhoneNo.DataBindings.Clear(

'display the records in the control
Guest.dsGuest.Tables("ClientDet").Select(
Me.txtTitle.DataBindings.Add(New Binding("Text", Guest.dsGuest.Tables("ClientDet"), "Title")
Me.txtForename.DataBindings.Add(New Binding("Text", Guest.dsGuest.Tables("ClientDet"), "Forename")
Me.txtSurname.DataBindings.Add(New Binding("Text", Guest.dsGuest.Tables("ClientDet"), "SurName")
Me.txtaddress.DataBindings.Add(New Binding("Text", Guest.dsGuest.Tables("ClientDet"), "Address")
Me.txtPostcode.DataBindings.Add(New Binding("Text", Guest.dsGuest.Tables("ClientDet"), "Postcode")
Me.txtorganisation.DataBindings.Add(New Binding("Text", Guest.dsGuest.Tables("ClientDet"), "OrgName")
Me.txtPhoneNo.DataBindings.Add(New Binding("Text", Guest.dsGuest.Tables("ClientDet"), "PhoneNo")

'place the values from the controls into the global varible
TBTitle = txtTitl
TBPubFName = txtForenam
TBPubLName = txtSurnam
TBPubAddr = txtaddres
TBPubPCode = txtPostcod
TBPubPhoneNo = txtPhoneN
TBPubOrg = txtorganisatio
LabelExClientID = lblExClientI

Me.Close(

i declare the variables at the top of the form like so
Public Shared TBTitle As TextBo
Public Shared TBPubFName As TextBo
Public Shared TBPubLName As TextBo
Public Shared TBPubAddr As TextBo
Public Shared TBPubPCode As TextBo
Public Shared TBPubPhoneNo As TextBo
Public Shared TBPubOrg As TextBo

can anyone plz help
 
I can't see anything wrong from quickly browsing your code. Which line
throws the exception? In addition, do you have the database schema?

--
Carsten Thomsen
Enterprise Development with VS .NET, UML, and MSF
http://www.apress.com/book/bookDisplay.html?bID=105
Me said:
Hi,

The error i now recieve is:

Cant bind to property or coloumn Title on datacource. Parameter name: datamember

this message appears when i click the OK button on Form2. The message
does not end the application but my binding code does not run.
Here is my binding code:

Try
cn.Open()

da.Fill(Guest.dsGuest, "ClientDet")

txtTitle.DataBindings.Clear()
txtForename.DataBindings.Clear()
txtSurname.DataBindings.Clear()
txtaddress.DataBindings.Clear()
txtPostcode.DataBindings.Clear()
txtorganisation.DataBindings.Clear()
txtPhoneNo.DataBindings.Clear()

'display the records in the controls
Guest.dsGuest.Tables("ClientDet").Select()
Me.txtTitle.DataBindings.Add(New Binding("Text",
Guest.dsGuest.Tables("ClientDet"), "Title"))
Me.txtForename.DataBindings.Add(New Binding("Text",
Guest.dsGuest.Tables("ClientDet"), "Forename"))
Me.txtSurname.DataBindings.Add(New Binding("Text",
Guest.dsGuest.Tables("ClientDet"), "SurName"))
Me.txtaddress.DataBindings.Add(New Binding("Text",
Guest.dsGuest.Tables("ClientDet"), "Address"))
Me.txtPostcode.DataBindings.Add(New Binding("Text",
Guest.dsGuest.Tables("ClientDet"), "Postcode"))
Me.txtorganisation.DataBindings.Add(New Binding("Text",
Guest.dsGuest.Tables("ClientDet"), "OrgName"))
Me.txtPhoneNo.DataBindings.Add(New Binding("Text",
Guest.dsGuest.Tables("ClientDet"), "PhoneNo"))
 
Back
Top