how to get the record with paramater query in access
am 01.02.2006 09:18:41 von Kevin
Hi,
I defined in access a query for authentification with two parameters like
this:
SELECT id, name FROM table WHERE (name)=[na]) AND (pasw)=[pw]);
This works in access. I named this query "paswkl'
In ASP, i did this:
na=request.form("name")
pw=request.form("pasw")
set objdc = Server.CreateObject("ADODB.Connection")
objdc.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
server.mappath("\mydb.mdb") & ";"
objdc.paswkl na,pw
But then, how can i get the record?
I can't use:
Set rs = objdc.execute(sql)
if not rs.eof then
rsArray = rs.GetRows()
rec = UBound(rsArray, 2) + 1
because there is no sql statement anymore ...
Thanks
Kevin
Re: how to get the record with paramater query in access
am 01.02.2006 12:46:44 von reb01501
Kevin wrote:
> Hi,
>
> I defined in access a query for authentification with two parameters
> like this:
> SELECT id, name FROM table WHERE (name)=[na]) AND (pasw)=[pw]);
>
> This works in access. I named this query "paswkl'
>
> In ASP, i did this:
> na=request.form("name")
> pw=request.form("pasw")
>
> set objdc = Server.CreateObject("ADODB.Connection")
> objdc.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
> server.mappath("\mydb.mdb") & ";"
> objdc.paswkl na,pw
>
> But then, how can i get the record?
> I can't use:
> Set rs = objdc.execute(sql)
> if not rs.eof then
> rsArray = rs.GetRows()
> rec = UBound(rsArray, 2) + 1
> because there is no sql statement anymore ...
>
Here is the pattern I use:
Set rs=createobject("adodb.recordset")
objdc.paswkl na,pw, rs
if not rs.eof then rsArray = rs.GetRows()
rs.close:set rs = nothing
objdc.close: set objdc = nothing
if isarray(rsArray) then
'process the array
else
'inform user that no records were returned
end if
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Re: how to get the record with paramater query in access
am 01.02.2006 21:35:40 von Kevin
Thanks, it works now ...
"Bob Barrows [MVP]" wrote in message
news:e5EgsUyJGHA.208@tk2msftngp13.phx.gbl...
> Kevin wrote:
> > Hi,
> >
> > I defined in access a query for authentification with two parameters
> > like this:
> > SELECT id, name FROM table WHERE (name)=[na]) AND (pasw)=[pw]);
> >
> > This works in access. I named this query "paswkl'
> >
> > In ASP, i did this:
> > na=request.form("name")
> > pw=request.form("pasw")
> >
> > set objdc = Server.CreateObject("ADODB.Connection")
> > objdc.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
> > server.mappath("\mydb.mdb") & ";"
> > objdc.paswkl na,pw
> >
> > But then, how can i get the record?
> > I can't use:
> > Set rs = objdc.execute(sql)
> > if not rs.eof then
> > rsArray = rs.GetRows()
> > rec = UBound(rsArray, 2) + 1
> > because there is no sql statement anymore ...
> >
>
> Here is the pattern I use:
>
> Set rs=createobject("adodb.recordset")
> objdc.paswkl na,pw, rs
> if not rs.eof then rsArray = rs.GetRows()
> rs.close:set rs = nothing
> objdc.close: set objdc = nothing
> if isarray(rsArray) then
> 'process the array
> else
> 'inform user that no records were returned
> end if
>
>
> Bob Barrows
> --
> Microsoft MVP - ASP/ASP.NET
> Please reply to the newsgroup. This email account is my spam trap so I
> don't check it very often. If you must reply off-line, then remove the
> "NO SPAM"
>
>