Please help . What I am doing wrong

70 pts.
Tags:
.NET
Oracle development
Dim cmd As OracleCommand Dim ds As DataSet Dim dv As DataView Dim da As OracleDataAdapter = New OracleDataAdapter ' This does not work.. which is what I need, Country and State are entered by the user - cmd = New OracleCommand("Select state_code, state_name, state_status" & _ " FROM m_state" & _ " WHERE country_code = :country_code AND state_code = :state_code", objConnection) ' ------------------------------------------------------------------------------------- ' This works...----------------------------------------------------------------------- cmd = New OracleCommand("Select state_code, state_name, state_status" & _ " FROM m_state" & _ " WHERE country_code = 'USA' AND state_code = :state_code", objConnection) ' ------------------------------------------------------------------------------------- ' This works...----------------------------------------------------------------------- cmd = New OracleCommand("Select state_code, state_name, state_status" & _ " FROM m_state" & _ " WHERE country_code = :country_code AND state_code = 'FL'", objConnection) ' ------------------------------------------------------------------------------------- ' Parameter for State Code... cmd.Parameters.Add("state_code", txtState.Text) ' Parameter for Country Code... cmd.Parameters.Add(":country_code", txtCountryText) da.SelectCommand = cmd ' Bind Fields.. ClearBinding() ' Initialize a new instance of the DataSet object... ds = New DataSet ' Fill the DataSet object with data... da.Fill(ds, "m_state") ' Set the DataView object to the DataSet object... dv = New DataView(ds.Tables("m_state")) ' Set Bindings txtStateName.DataBindings.Add("Text", dv, "state_name") txtStatus.DataBindings.Add("Text", dv, "state_status")

Answer Wiki

Thanks. We'll let you know when a new response is added.

Have you tried adding the parameters this way : ?

<pre>cmd.Parameters.Add(“STATE_CODE”, OracleType.Int32).Value = txtState.Text</pre>

or this way: ?

<pre>Dim parmSTATE = _
New OracleParameter(“STATE_CODE”, OracleType.Int32)
parmSTATE .Direction = ParameterDirection.Input
parmSTATE .Value = txtState.Text
cmd.Parameters.Add(parmSTATE )</pre>

Also, you are adding the state_code parameter this way:

cmd.Parameters.Add(“state_code”, txtState.Text)

but for country_code you have an extra colon:

cmd.Parameters.Add(“:country_code”, txtCountryText)

was this a typo ?

Hi Carlosdl. Thanks for respondoing.. I solve the problem. What you have to do is sequence the
.Parameters.Add in the same sequence as they are in the select.

The country first then the state. The colon was missing from the state.

Thanks

Regards

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • carlosdl
    If you are getting errors, please post the error message.
    68,650 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following