Friday, March 16, 2012

parameter query in MDB

I have this query (qryZipLike) in an MDB file. It accesses a function
geo_distance() and requires input parms for the three parameters.

SELECT tblPrimary.Zip, tblPrimary.State, tblPrimary.City,
geo_distance([@dotnet.itags.org.LAT1],[@dotnet.itags.org.LON1],tblPrimary.Lat,tblPrimary.Lon) AS dist1
FROM tblPrimary
WHERE Zip Like [@dotnet.itags.org.P1];

I am trying to access this query from C# in asp.net using ado.net. I am
really not sure how to do so, but have tried the following code.

OleDbCommand sql1 = new OleDbCommand("qryLikeZip", oleDbConnection1);
theSQL = "SELECT City,Zip,dist1 FROM qryZipLike";

sql1.CommandText = theSQL;
OleDbParameter myparm;

myparm = sql1.Parameters.Add(new
OleDbParameter("@dotnet.itags.org.LAT1",OleDbType.Double,8));
myparm.Direction = System.Data.ParameterDirection.Input;
myparm.Value = lat1;

myparm = sql1.Parameters.Add(new
OleDbParameter("@dotnet.itags.org.LON1",OleDbType.Double,8));
myparm.Direction = System.Data.ParameterDirection.Input;
myparm.Value = long1;

myparm = sql1.Parameters.Add(new OleDbParameter("@dotnet.itags.org.P1",OleDbType.VarChar,4));
myparm.Direction = System.Data.ParameterDirection.Input;
myparm.Value = "030*";

dr = sql1.ExecuteReader();

I get this error at the ExecuteReader call...

Undefined function 'geo_distance' in expression

Can anyone help me with this?Let the microsoft access code generator write the code for you.

http://www.eggheadcafe.com/articles...e_generator.asp

--
2005 Microsoft MVP C#
Robbe Morris
http://www.robbemorris.com
http://www.learncsharp.net/home/listings.aspx

"Msnews" <daveberg@.adelphia.net> wrote in message
news:OXx7%23BALFHA.1136@.TK2MSFTNGP10.phx.gbl...
>I have this query (qryZipLike) in an MDB file. It accesses a function
>geo_distance() and requires input parms for the three parameters.
> SELECT tblPrimary.Zip, tblPrimary.State, tblPrimary.City,
> geo_distance([@.LAT1],[@.LON1],tblPrimary.Lat,tblPrimary.Lon) AS dist1
> FROM tblPrimary
> WHERE Zip Like [@.P1];
> I am trying to access this query from C# in asp.net using ado.net. I am
> really not sure how to do so, but have tried the following code.
> OleDbCommand sql1 = new OleDbCommand("qryLikeZip", oleDbConnection1);
> theSQL = "SELECT City,Zip,dist1 FROM qryZipLike";
> sql1.CommandText = theSQL;
> OleDbParameter myparm;
> myparm = sql1.Parameters.Add(new
> OleDbParameter("@.LAT1",OleDbType.Double,8));
> myparm.Direction = System.Data.ParameterDirection.Input;
> myparm.Value = lat1;
> myparm = sql1.Parameters.Add(new
> OleDbParameter("@.LON1",OleDbType.Double,8));
> myparm.Direction = System.Data.ParameterDirection.Input;
> myparm.Value = long1;
> myparm = sql1.Parameters.Add(new
> OleDbParameter("@.P1",OleDbType.VarChar,4));
> myparm.Direction = System.Data.ParameterDirection.Input;
> myparm.Value = "030*";
> dr = sql1.ExecuteReader();
>
> I get this error at the ExecuteReader call...
> Undefined function 'geo_distance' in expression
> Can anyone help me with this?
>

0 comments:

Post a Comment