PC Review


Reply
Thread Tools Rate Thread

Bind variables in vb.net

 
 
RDS
Guest
Posts: n/a
 
      18th Aug 2005
Does anyone know how to do the following vb6 code using bind variables
for oracle dbs, in .net?

dim cmdMyCommand as ADODB.COMMAND
Set cmdMyCommand = New ADODB.COMMAND
With cmdMyCommand
.ActiveConnection = objConn
.CommandText = "Select COL1 from TABLENAME Where COL2 = ?"
.Parameters.Append .CreateParameter( "", _
adVarChar, adParamInputOutput, "SOMESTUFF")
Set rsMyRecordset = .Execute
End With

In the .net version I was trying to write it seems to complain about
the ?, in my code there are LIKE statements in the SQL as well, how can
bind variables be used [LIKE %?% doesn't work]

I was doing somthing like this:

Dim cmdMyCommand As Oracle.DataAccess.Client.OracleCommand
Dim pInParam As Oracle.DataAccess.Client.OracleParameter

cmdMyCommand = New Oracle.DataAccess.Client.OracleCommand
With cmdMyCommand
.Connection = oCon
.CommandText = "Select COL1 from TABLENAME Where COL2 = ?"
'OR .commandText = "Select COL1 from TABLENAME where value LIKE% ?
%"
.Prepare()
pInParam = New Oracle.DataAccess.Client.OracleParameter
pInParam.Value = sString.ToString()
.Parameters.Add(pInParam)
.ExecuteNonQuery()
End With

 
Reply With Quote
 
 
 
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      18th Aug 2005
RDS,

Binding in Net is not the same as setting an sql parameter, which you cannot
bind.

I assume that your question is the last. We have two samples on our website
about SQL sever and OleDb for that.

http://www.windowsformsdatagridhelp....6-7139b8970071

http://www.windowsformsdatagridhelp....3-eb8b44af0137


We don't have it for Oracle however see for the more general description
this

http://msdn.microsoft.com/library/de...eterstopic.asp

Did you know that for this kind of ADODB question the more properiate
newsgroups is

Adonet
news://msnews.microsoft.com/microsof...amework.adonet

Web interface:
http://communities2.microsoft.com/co...amework.adonet

I hope this helps,

Cor


 
Reply With Quote
 
RDS
Guest
Posts: n/a
 
      18th Aug 2005
Thanks

 
Reply With Quote
 
Paul Clement
Guest
Posts: n/a
 
      18th Aug 2005
On Thu, 18 Aug 2005 09:05:14 +0200, "Cor Ligthert [MVP]" <(E-Mail Removed)> wrote:

¤ RDS,
¤
¤ Binding in Net is not the same as setting an sql parameter, which you cannot
¤ bind.
¤

Cor,

The use of "Bind variables" is a different concept than "data binding". See the following:

http://www.rittman.net/archives/000832.html

Specifically he's just asking about the use of the Command object and named parameters. So if you
have a PL/SQL statement like the following:

select salary from employees where employee_number = :empno

You would add a Parameter object with the name "empno" to the Parameter collection in order to
support bind variables.


Paul
~~~~
Microsoft MVP (Visual Basic)
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bind variables and sql cptkirkh Microsoft ADO .NET 4 8th Aug 2007 02:55 PM
How to bind variables everymn@yahoo.com Microsoft Access VBA Modules 5 21st Nov 2006 11:54 PM
Bind Variables Using ODP.NET vm.shinde@gmail.com Microsoft ADO .NET 0 24th Feb 2006 12:37 PM
BIND VARIABLES using 'Like' in the sql RDS Microsoft ADO .NET 1 18th Aug 2005 07:03 PM
Is there a way to bind form variables? dave Microsoft VB .NET 0 18th Nov 2003 08:27 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:50 AM.