bind variables and sql

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I a trying to store certain sql queries in a table to reference
later. I want to perform a sql query to see if they are in the table
and i want to use bind variables. HOw can i do this?

Here is a sample of my code:
Dim sqltorun As String = "select max(ec_export_number) from
event_campaign " & _
" where EC_PURPOSE
= :event_purpose AND EC_ITEM_SENT = :item_sent" & _
" AND EC_SQL = :sql_totalcount "




Dim cmd As New OracleCommand(sqltorun, myConnection)



Try
cmd.Connection.Open()
Catch ex As Exception
MsgBox("Please close the program and reopen to establish a
new connection and if it happens again call MIS" + export_date,
MsgBoxStyle.OkOnly, title)
End Try

cmd.Parameters.Add(":sql_totalcount", OracleDbType.Varchar2).Value =
"select cli_rid from dual"
cmd.Parameters.Add(":event_purpose",
OracleDbType.Varchar2).Value = "20070511TXAM"
cmd.Parameters.Add(":item_sent", OracleDbType.Varchar2).Value
= "POSTCARD"

Try 'go and get the export number if false no query has been run
before


export_num = cmd.ExecuteScalar

When i get to this step i get illegal number or vairable as the
exception.
This sql code works just fine when i run it in sql plus or toad.
Thanks for your help.

.



Relevant Pages

  • Re: Equivalent of Get Next Extended to retrieve only unique keys?
    ... The only real "extra" stuff is pertaining to SQL query optimization. ... Bill Bach wrote: ... Retaining the ability to filter on multiple>> items would probably ...
    (comp.databases.btrieve)
  • Re: Setting a Default Value
    ... the make the Sql call from within Application_Start in Global.asax. ... the query string value each time I needed to ... going to assign the default value through a database query. ... run the following SQL query: select * from table where x = 1 ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: MultiSelect Property
    ... > For Each vItm In Me!lbSelectContract.ItemsSelected ... > Dim stCriteria As String ... >> SQL query). ... >> the multiselect list box appears in the SQL query. ...
    (microsoft.public.access.devtoolkits)
  • RE: Revisit an older post, looking for SQL help on adding range data f
    ... I guess you're using a SQL query to manipulate data via Data, ... missing was the connection between Excel named ranges and SQL ... "Replace the displayed SQL code with an adapted version of this:". ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Crosstab counting
    ... Michel, thanks for the response. ... I've built the table as shown, ... After reading the syntex sql multiple times, I can see the statement forming ... The SQL query is the same as yours: ...
    (microsoft.public.access.queries)