G
Guest
H
I am running a stored procedure on the SelectedIndexChanged event of a combobox. this stored procedure retrieves details from a database. i want to bind the results to the controls on my form but it doesnt work!! here is my cod
'Display the caravan details based on the length and the caravan model
Dim cmdEditCara As New SqlCommand("SPSelCaraDetailsOnModelLength", Conn
Dim da As New SqlDataAdapter(cmdEditCara
Dim ds As New DataSet(
'run a command to fill the textboxes et
cmdEditCara.CommandType = CommandType.StoredProcedur
'declare the parameter
cmdEditCara.Parameters.Add("@CaraModel", SqlDbType.Char, 50
cmdEditCara.Parameters.Add("@Length", SqlDbType.Char, 10
'now set the value
cmdEditCara.Parameters("@CaraModel").Value = CBoxEditCaraName.Tex
cmdEditCara.Parameters("@Length").Value = CBoxEditCaraLength.Tex
Tr
Conn.Open(
da.Fill(ds, "EditCara"
'display the records in the various control
ds.Tables("dtCaravan_Details").Select(
Me.txtTotCaraOnSite.DataBindings.Add(New Binding("Text", ds.Table
("EditCara"), "Caravan_Model")
Me.txtBeds.DataBindings.Add(New Binding("Text", ds.Tables("EditCara"), "Beds")
Me.txtPrice.DataBindings.Add(New Binding("Text", ds.Tables("EditCara"), "Cost")
Catch ex As Exceptio
MsgBox(ex.Message
Finall
Conn.Close(
End Tr
The problem im having is that i keep getting a message that states
Object reference not set to an instance of an objec
None of the controls display any results
Does anyone know what i am doin wrong
This is the first time im using the databind method so i need as much advise as poss :
Also once the controls are bound to the results of the query can i update the values in them
for example i want the user to be able to update the values in the textbox and then push the results back to the database using and u[pdate command. Can this be done through the use of the databinding method
I am running a stored procedure on the SelectedIndexChanged event of a combobox. this stored procedure retrieves details from a database. i want to bind the results to the controls on my form but it doesnt work!! here is my cod
'Display the caravan details based on the length and the caravan model
Dim cmdEditCara As New SqlCommand("SPSelCaraDetailsOnModelLength", Conn
Dim da As New SqlDataAdapter(cmdEditCara
Dim ds As New DataSet(
'run a command to fill the textboxes et
cmdEditCara.CommandType = CommandType.StoredProcedur
'declare the parameter
cmdEditCara.Parameters.Add("@CaraModel", SqlDbType.Char, 50
cmdEditCara.Parameters.Add("@Length", SqlDbType.Char, 10
'now set the value
cmdEditCara.Parameters("@CaraModel").Value = CBoxEditCaraName.Tex
cmdEditCara.Parameters("@Length").Value = CBoxEditCaraLength.Tex
Tr
Conn.Open(
da.Fill(ds, "EditCara"
'display the records in the various control
ds.Tables("dtCaravan_Details").Select(
Me.txtTotCaraOnSite.DataBindings.Add(New Binding("Text", ds.Table
("EditCara"), "Caravan_Model")
Me.txtBeds.DataBindings.Add(New Binding("Text", ds.Tables("EditCara"), "Beds")
Me.txtPrice.DataBindings.Add(New Binding("Text", ds.Tables("EditCara"), "Cost")
Catch ex As Exceptio
MsgBox(ex.Message
Finall
Conn.Close(
End Tr
The problem im having is that i keep getting a message that states
Object reference not set to an instance of an objec
None of the controls display any results
Does anyone know what i am doin wrong
This is the first time im using the databind method so i need as much advise as poss :
Also once the controls are bound to the results of the query can i update the values in them
for example i want the user to be able to update the values in the textbox and then push the results back to the database using and u[pdate command. Can this be done through the use of the databinding method