Home > Archive > FoxPro Help and Support > January 2006 > How to use parameters with ADO.NET OleDBCommand and Parameters collection









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How to use parameters with ADO.NET OleDBCommand and Parameters collection
bzamfir@gmail.com

2006-01-02, 8:25 pm

Hi,

I want to write a ASP.NET web service, which retrieves data form a VFP
database using VFP OleDB driver.

And I don't want to create SQL statements by combining SQL string with
parameter values, but instead I want to use Parameters colection.

I know how to do that with SQLCommand and SQLParameters, but that seems
to not work with OleDbParameter

Specifically, if I assign to SQLCommand the following string "select *
from mytable where id = nId" and I set a parameter for this
OleDBCommand as nID with value 1, when I excute the reader, I get the
error "SQL: Column 'nID' is not found"

I tried to assign parameter as @nID not the same result

Can anyone help me?

Thank you

Eric den Doop

2006-01-03, 7:24 am

Here's a VB.NET sample:

Dim connstr As String = "provider=VFPOLEDB.1;data
source='tastrade. dbc';password='';use
r id=''"
Dim conn As New System.Data.OleDb.OleDbConnection
conn.ConnectionString = connstr
Dim cmd As New System.Data.OleDb.OleDbCommand
cmd.CommandType = CommandType.Text
cmd.CommandText = "UPDATE customer SET company_name = ?, contact_name = ?
WHERE customer_id = [ALFKI]"
cmd.Connection = conn
Dim p1 As New System.Data.OleDb.OleDbParameter
p1.Value = "VFP"
cmd.Parameters.Add(p1)
Dim p2 As New System.Data.OleDb.OleDbParameter
p2.Value = "OLEDB"
cmd.Parameters.Add(p2)
Try
conn.Open()
Dim tally As Integer = cmd.ExecuteNonQuery()
conn.Close()
Catch ex As Exception
Debug.Write(ex.Message)
End Try

--
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts
VFP MVP


<bzamfir@gmail.com> wrote in message
news:1136253573.450806.234100@g49g2000cwa.googlegroups.com...
> Hi,
>
> I want to write a ASP.NET web service, which retrieves data form a VFP
> database using VFP OleDB driver.
>
> And I don't want to create SQL statements by combining SQL string with
> parameter values, but instead I want to use Parameters colection.
>
> I know how to do that with SQLCommand and SQLParameters, but that seems
> to not work with OleDbParameter
>
> Specifically, if I assign to SQLCommand the following string "select *
> from mytable where id = nId" and I set a parameter for this
> OleDBCommand as nID with value 1, when I excute the reader, I get the
> error "SQL: Column 'nID' is not found"
>
> I tried to assign parameter as @nID not the same result
>
> Can anyone help me?
>
> Thank you
>



Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com