PC Review


Reply
Thread Tools Rate Thread

Another parameter question

 
 
RICK
Guest
Posts: n/a
 
      20th Apr 2009
Must be doing something wrong here as my query is coming up with no records.
Please help

dbconn.Open()
sql="SELECT * FROM WebQry_NCList_FamilyList where Family = '@family'"
DBSQLCOMMAND.Parameters.Add("@family","Smith")
dbcomm=New OleDbCommand(sql,dbconn)
 
Reply With Quote
 
 
 
 
Cor Ligthert[MVP]
Guest
Posts: n/a
 
      20th Apr 2009
Rick,

You have to do something with that dbcomm or either use a OleDbAdapter.

However with only this code there will not come up any record

Cor

"RICK" <(E-Mail Removed)> wrote in message
newsCB55FFD-B8EF-4497-AA2A-(E-Mail Removed)...
> Must be doing something wrong here as my query is coming up with no
> records.
> Please help
>
> dbconn.Open()
> sql="SELECT * FROM WebQry_NCList_FamilyList where Family = '@family'"
> DBSQLCOMMAND.Parameters.Add("@family","Smith")
> dbcomm=New OleDbCommand(sql,dbconn)


 
Reply With Quote
 
RICK
Guest
Posts: n/a
 
      20th Apr 2009
Here is the full code. Will this code help in trying to decipher my issue?

_______________

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

<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"))
Dim DBSQLCOMMAND As SqlClient.SqlCommand

DBSQLCOMMAND = New SqlClient.SqlCommand
DBSQLCOMMAND.Parameters.Add("@family","Smith")

dbconn.Open()



SQL="SELECT * FROM WebQry_FamilyList where Family='@family'"

dbcomm=New OleDbCommand(sql,dbconn)

dbread=dbcomm.ExecuteReader()
family.DataSource=dbread
family.DataBind()
dbread.Close()
dbconn.Close()
end sub


</script>

<html>
<body>

<form runat="server">
<aspataList
id="family"
runat="server"
cellpadding="2"
cellspacing="2"
borderstyle="inset"
backcolor="#e8e8e8"
width="50%"
headerstyle-font-name="Verdana"
headerstyle-font-size="12pt"
headerstyle-horizontalalign="center"
headerstyle-font-bold="True"
itemstyle-backcolor="#778899"
itemstyle-forecolor="#ffffff"
footerstyle-font-size="9pt"
footerstyle-font-italic="True">

<HeaderTemplate>
Family Table
</HeaderTemplate>

<ItemTemplate><%#Container.DataItem("family")%></ItemTemplate>

<FooterTemplate>
Source: The Database
</FooterTemplate>

</aspataList>
</form>

</body>
</html>

"Cor Ligthert[MVP]" wrote:

> Rick,
>
> You have to do something with that dbcomm or either use a OleDbAdapter.
>
> However with only this code there will not come up any record
>
> Cor
>
> "RICK" <(E-Mail Removed)> wrote in message
> newsCB55FFD-B8EF-4497-AA2A-(E-Mail Removed)...
> > Must be doing something wrong here as my query is coming up with no
> > records.
> > Please help
> >
> > dbconn.Open()
> > sql="SELECT * FROM WebQry_NCList_FamilyList where Family = '@family'"
> > DBSQLCOMMAND.Parameters.Add("@family","Smith")
> > dbcomm=New OleDbCommand(sql,dbconn)

>
>

 
Reply With Quote
 
Cor Ligthert[MVP]
Guest
Posts: n/a
 
      20th Apr 2009
> The parameter placeholder includes handling the appropriate delimiters.
> You shouldn't include them...
>

I missed that one.

>
> BTW I'm not even sure it will work. AFAIK Access doesn't support named
> parameters.


No but you can use @Family, however it is nothing more then ?.
Like you wrote being the unnamed placeholder that are distinguished by their
positions
and not by their names

 
Reply With Quote
 
RICK
Guest
Posts: n/a
 
      20th Apr 2009
OK, so what I am really after here in the very end is to somehow get my query
to read
sql="SELECT * FROM WebQry_NCList_FamilyList where Family = strfamily

where strfamily is some variable that comes from a form on the previous
page. Can that be done? And if so, how?

 
Reply With Quote
 
RICK
Guest
Posts: n/a
 
      20th Apr 2009
Well, kind of answered my question:

Dim strFamily
strFamily = "Acanthaceae"

SQL="SELECT * FROM WebQry_NCList_FamilyList where Family= '" + strFamily + "'"

Now, how can I make this more secure?

"RICK" wrote:

> OK, so what I am really after here in the very end is to somehow get my query
> to read
> sql="SELECT * FROM WebQry_NCList_FamilyList where Family = strfamily
>
> where strfamily is some variable that comes from a form on the previous
> page. Can that be done? And if so, how?
>

 
Reply With Quote
 
RICK
Guest
Posts: n/a
 
      20th Apr 2009
Again, I think my question may have been answered. In classic I have been
using

set rs=server.createobject("adodb.recordset")
conn.MyProcedure parmval1,...,parmvalN, rs

Was wondering if something similar could be used in .net.

A post from Barrows follows:

"You can also use this technique if your procedure returns a
recordset:
set rs=server.createobject("adodb.recordset")
'optionally, set the cursor location and type properties
conn.MyProcedure parmval1,...,parmvalN, rs

This technique does not work in ADO.Net, so if you are considering
porting to dotnet, then you should avoid this technique."

If someone can verify for me that this is still the case I will stop trying
to port my stuff over to .net.


"RICK" wrote:

> Well, kind of answered my question:
>
> Dim strFamily
> strFamily = "Acanthaceae"
>
> SQL="SELECT * FROM WebQry_NCList_FamilyList where Family= '" + strFamily + "'"
>
> Now, how can I make this more secure?
>
> "RICK" wrote:
>
> > OK, so what I am really after here in the very end is to somehow get my query
> > to read
> > sql="SELECT * FROM WebQry_NCList_FamilyList where Family = strfamily
> >
> > where strfamily is some variable that comes from a form on the previous
> > page. Can that be done? And if so, how?
> >

 
Reply With Quote
 
Cor Ligthert[MVP]
Guest
Posts: n/a
 
      20th Apr 2009
Rick,

There is probably really nobody here who cares about it of you go to Net of
not.

There have been as well a lot of people who did not want to go to disc,
they stayed with the punch card.

This kind of behaviour is solved automatically.

Cor

"RICK" <(E-Mail Removed)> wrote in message
news:BD32C75C-0CDD-470F-AE49-(E-Mail Removed)...
> Again, I think my question may have been answered. In classic I have been
> using
>
> set rs=server.createobject("adodb.recordset")
> conn.MyProcedure parmval1,...,parmvalN, rs
>
> Was wondering if something similar could be used in .net.
>
> A post from Barrows follows:
>
> "You can also use this technique if your procedure returns a
> recordset:
> set rs=server.createobject("adodb.recordset")
> 'optionally, set the cursor location and type properties
> conn.MyProcedure parmval1,...,parmvalN, rs
>
> This technique does not work in ADO.Net, so if you are considering
> porting to dotnet, then you should avoid this technique."
>
> If someone can verify for me that this is still the case I will stop
> trying
> to port my stuff over to .net.
>
>
> "RICK" wrote:
>
>> Well, kind of answered my question:
>>
>> Dim strFamily
>> strFamily = "Acanthaceae"
>>
>> SQL="SELECT * FROM WebQry_NCList_FamilyList where Family= '" + strFamily
>> + "'"
>>
>> Now, how can I make this more secure?
>>
>> "RICK" wrote:
>>
>> > OK, so what I am really after here in the very end is to somehow get my
>> > query
>> > to read
>> > sql="SELECT * FROM WebQry_NCList_FamilyList where Family = strfamily
>> >
>> > where strfamily is some variable that comes from a form on the previous
>> > page. Can that be done? And if so, how?
>> >


 
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
Another Parameter Question Stephen Lynch Microsoft ADO .NET 2 4th Sep 2006 05:59 PM
IIF parameter question BenKan Lin via AccessMonster.com Microsoft Access Queries 1 13th May 2005 10:01 AM
error STOP:0x0000007B (parameter, parameter, parameter, parameter) robert35 Microsoft Access Getting Started 1 15th Dec 2004 03:28 PM
asp.net C# parameter question Eric van der Niet Microsoft C# .NET 2 14th Dec 2004 08:47 AM
Parameter Question =?Utf-8?B?TWlrZSBKb2huc29u?= Microsoft Access Form Coding 1 1st Aug 2004 03:07 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:24 AM.