anagm
asked on
Passing a parameter to a SQL statement with Oracle Database
Hello,
I am using an Oracle Database.
I am trying to pass a parameter to the SQL statement.
My orginal SQL which gets the records is as follows:
SELECT rug.user_group_id, rug.user_group_desc, rh.code_hotel
FROM rpt_user_groups rug, rpt_user_group_xref rugx, rpt_hotels rh
WHERE rugx.rpt_user_group_parent _id in 1 <-------------------i have to pass a parameter here instead of 1
AND rugx.rpt_user_group_child_ id = rug.user_group_id
AND rug.user_group_id = rh.user_group_id(+) ORDER BY rug.user_group_desc,rug.us er_group_i d
i am trying like below:
Protected Sub RadTreeView1_NodeExpand(By Val sender As Object, ByVal e As RadTreeNodeEventArgs) Handles RadTreeView1.NodeExpand
Dim oradb As String = "Data Source=(DESCRIPTION=(ADDRE SS_LIST=" _
+ "(ADDRESS=(PROTOCOL=TCP)(H OST=)(PORT =1521)))" _
+ "(CONNECT_DATA=(SERVER=DED ICATED)(SE RVICE_NAME =something )));" _
+ "User Id=something;Password=some thing;"
Dim conn As New OracleConnection(oradb)
conn.Open()
Dim sql As New OracleCommand("SELECT rug.user_group_id, rug.user_group_desc, rh.code_hotel FROM rpt_user_groups rug, rpt_user_group_xref rugx, rpt_hotels rh WHERE rugx.rpt_user_group_parent _id in @ParentId AND rugx.rpt_user_group_child_ id = rug.user_group_id AND rug.user_group_id = rh.user_group_id(+) ORDER BY rug.user_group_desc,rug.us er_group_i d", conn) ' VB.NET
sql.Parameters.Add("@Paren tId", e.Node.Value)
Dim adapter As New OracleDataAdapter(sql) --- my parameter is not replaced with '1'
Dim data As New DataTable()
adapter.Fill(data) <----- fails here with message (An exception of type 'Oracle.DataAccess.Client. OracleExce ption' occurred in Oracle.DataAccess.dll but was not handled in user code.Additional information: External component has thrown an exception.)
End Sub
when i execute the query i get a error pop-up: ORA-00936 missing expression
any help would be greatly appreciated.
anagm
I am using an Oracle Database.
I am trying to pass a parameter to the SQL statement.
My orginal SQL which gets the records is as follows:
SELECT rug.user_group_id, rug.user_group_desc, rh.code_hotel
FROM rpt_user_groups rug, rpt_user_group_xref rugx, rpt_hotels rh
WHERE rugx.rpt_user_group_parent
AND rugx.rpt_user_group_child_
AND rug.user_group_id = rh.user_group_id(+) ORDER BY rug.user_group_desc,rug.us
i am trying like below:
Protected Sub RadTreeView1_NodeExpand(By
Dim oradb As String = "Data Source=(DESCRIPTION=(ADDRE
+ "(ADDRESS=(PROTOCOL=TCP)(H
+ "(CONNECT_DATA=(SERVER=DED
+ "User Id=something;Password=some
Dim conn As New OracleConnection(oradb)
conn.Open()
Dim sql As New OracleCommand("SELECT rug.user_group_id, rug.user_group_desc, rh.code_hotel FROM rpt_user_groups rug, rpt_user_group_xref rugx, rpt_hotels rh WHERE rugx.rpt_user_group_parent
sql.Parameters.Add("@Paren
Dim adapter As New OracleDataAdapter(sql) --- my parameter is not replaced with '1'
Dim data As New DataTable()
adapter.Fill(data) <----- fails here with message (An exception of type 'Oracle.DataAccess.Client.
End Sub
when i execute the query i get a error pop-up: ORA-00936 missing expression
any help would be greatly appreciated.
anagm
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thank you, Goran.
anagm
anagm
ASKER
Dim sql As New OracleCommand("SELECT rug.user_group_id, rug.user_group_desc, rh.code_hotel FROM rpt_user_groups rug, rpt_user_group_xref rugx, rpt_hotels rh WHERE rugx.rpt_user_group_parent
sql.Parameters.Add(":Paren