Parameters in .net (Accessing MS Access)

R

RICK

In the following code you will note a select statement that says "SELECT *
FROM WebQry_List". The MS Access query needs a single parameter passed to it
to be able to run. How do you add that parameter in the following code. I
have tried parameters.add but am apparently having syntax problems. Please
advise!! Thanks.


<%@ Import Namespace="System.Data.OleDb" %>

<script runat="server">
sub Page_Load
dim dbconn,sql,dbcomm,dbread
dbconn=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" &
server.mappath("/databases/cpcweb.mdb"))
dbconn.Open()
sql="SELECT * FROM WebQry_List"
dbcomm=New OleDbCommand(sql,dbconn)
dbread=dbcomm.ExecuteReader()
family.DataSource=dbread
family.DataBind()
dbread.Close()
dbconn.Close()
end sub
 
C

Cor Ligthert[MVP]

Rick,

I gave you the answer on that already in the message in the other newsgroup.

My intention was that you would read that and ask this kind of questions
next time in this newsgroup, because you asked what was a better newsgroup
for AdoNet questions.

Cor
 
R

RICK

I do have a follow-up.

In my classic pages I am passing those parameters similar to the following:

<%
Set rsTemp = server.createobject("adodb.recordset")
dbconn.WebQry_List varRequestParm, rsTemp
$>

Is there anyway to do that in .net?
 
C

Cor Ligthert[MVP]

Why do you not look in that first newsgroup that you visited and where I
gave a sample?

Cor
 
R

RICK

I did take a look at the page that was referenced but unless I am missing
something I don't believe that the parameters are being passed similar to my
follow-up question. If I am missing something, please advise.

Thanks,

Rick
 
C

Cor Ligthert[MVP]

From that page

\\\
command.Parameters.Add("@p1", OleDbType.Char, 3).Value = "a")
///

Cor
 
R

RICK

Thanks, So .Value="a" than get replaced with .Value=strValue.

What I am trying to do is to get rid of the sql statements in the code and
get to the query that is written in MS Access.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top