Showing posts with label query. Show all posts
Showing posts with label query. Show all posts

Thursday, March 29, 2012

Passing Value Query

Hi,

I have an e-commerce website written in asp 1.1, vb.net and utilising an access database. Within the database I have a ProductID value to identify each product. Within the following sub procedure I want to be able to reference this value as I want to be able to check if there are enough items in stock. The code below uses the cartitemID and quantity as variables. However to reference individual items in the database I surely will need to pass the ProductID value. How should I approach this ?

[CODE]

Sub dgCart_Update(sender As Object, e As DataGridCommandEventArgs)

Dim intCartitemID As Integer
Dim txtQuantity As TextBox
Dim intQuantity As Integer

'Passes ProductID as sender

'Dim intProductID As Integer ??

intCartitemID = dgCart.DataKeys(e.Item.ItemIndex)
txtQuantity = e.Item.FindControl("txtQuantity")
intQuantity = txtQuantity.Text

'Define intQuantityInStock and reference to CheckQuantity function
Dim intQuantityInStock As Integer = CheckQuantity(intProductID)

'If statement to check enough quantity in stock
If intQuantityInStock < intQuantity
lblError.Text = "This item is currently low in stock. Please select an alternative</b>"
lblError.Visible = True
Else
Dim strSQL As String = "UPDATE [tblCartItems] SET [intQuantityOrder]=@dotnet.itags.org.Quantity WHERE "& _
"intCartitemID = @dotnet.itags.org.intCartitemID"

Dim dbCommand As New OleDbCommand(strSQL, dbConnection)

Dim cmd As New OleDbCommand

dbCommand.Parameters.Add("@dotnet.itags.org.Quantity", intQuantity)
dbCommand.Parameters.Add("@dotnet.itags.org.intCartitemID", intCartitemID)

dbConnection.Open()
dbCommand.ExecuteNonQuery()
dbConnection.Close()

dgCart.EditItemIndex = -1
dgCart.DataSource = DisplayCart()
dgCart.DataBind()

End If

End Sub
[/CODE]

You should be able to set this value in, say the CommandArgument of the button that is being clicked

ex:

<asp:Button
ID="btnAddToCart" runat="server"
CommandArgument='<%# Eval( "ProductID" ) %>'
CommandName="Product"
Text="Add To Cart" />

Then in your code behind, assign intProductID = (int) e.CommandArgument

Depending on what else you are doing with your grid, you may have to wrap an "if" around some code, checking if e.CommandName == "Product"


Thanks - unfortunately I'm not using a button in this instance. How else could I approach it ?


Fixed it thanks

Passing values between asp.net pages.

In asp you called a new page and passed any variable information through a query string.
Can some one tell me what the best practice is in asp.net to get information from one asp.net page to another ?

Or at least what the options wereYou can do this exactly as you did in ASP.
If you didn't want to continue using the querystring you could use cookies, sessions, or some other choices. But the querystring in a browser is a querystring in a browser - you can read one or create one just as you always did.

Monday, March 26, 2012

Passing Values from one page to another

I am passing ID of login user as Session variable and i hv to pass id of one more item and that i m passing in query string.But this is not safe, so how can i encrypt and decrypt that id so if user make some changes in id in addressbar of explorer, it didn't get the data.You can use this link to encrypt the data before putting it in a session variable, then decrypt the data again when you want to read it:

Encryption/Decryption with .NET

regards
But i m not using session variable in 2nd case. Ihv to pass the 2nd id in query string. But i want encryption and decruption for that or is that possible that quesry string not visile to end user.

passing values in html

Is this the right way topass values to query string
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="~/Admin.aspx?Token=ABC">Go To Admin Page</asp:HyperLink></div>"bobby" <bobby@.discussions.microsoft.comwrote in message
news:5BD2FD98-37E7-4311-A29A-F82D26B80CC2@.microsoft.com...

Quote:

Originally Posted by

Is this the right way to pass values to query string
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="~/Admin.aspx?Token=ABC">Go To Admin
Page</asp:HyperLink></div>


Yes, assuming there is an opening <divtag a bit further up...

--
Mark Rae
ASP.NET MVP
http://www.markrae.net
There is more than one "right way" to do this kind of thing, but the
technique you've shown is indeed valid.

Here are some other ways to pass data around too:
http://SteveOrr.net/articles/PassData.aspx
--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"bobby" <bobby@.discussions.microsoft.comwrote in message
news:5BD2FD98-37E7-4311-A29A-F82D26B80CC2@.microsoft.com...

Quote:

Originally Posted by

Is this the right way topass values to query string
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="~/Admin.aspx?Token=ABC">Go To Admin
Page</asp:HyperLink></div>

Passing variable to SQL string is not working.

Hi folks,
The problem I have is that a query string works if hard-coded but
if I pass a variable to it, it does not work as shown here.
This works:
querystring="SELECT * FROM USERS WHERE CNAME = 'MICROSOFT'"
This does not work:
Dim var as string
var = "Microsoft"
querystring="SELECT * FROM USERS WHERE CNAME = " & 'var'"
I have 2 DropDownList controls.
The first control is populated with a dataset of company names.
The second control is populated with a dataset of contact names for
the company that was selected in the first control.
The first control has an OnSelectedIndexChanged event handler.
The first control has a datasource set equal to a function named
GetCompanyNames.
The second control has a datasource set equal to a function named
GetContactNames.
In the OnSelectedIndexChanged event handler, I call the GetContactNames
function to
populate the second control with Contact Names that are associated with the
Company
Name selected in the first control.
All is working well, but the Contact Names in the second control do not
change as
different companies are selected in the first control.
What follows is a pseudo code description of my code:
' THESE ARE CALLED AS GLOBAL VARIABLES AT TOP OF THE PAGE
Dim coName as string
Dim dsCompanyNames as DataSet = New DataSet ( )
Dim dsContacts as DataSet = New DataSet ()
' THIS IS MY OnSelectedIndexChanged EVENT HANDLER
Sub ddlTo_SelectedIndexChanged(sender As Object, e As EventArgs)
Dim list As DropDownList = CType(sender, DropDownList)
coName=list.SelectedItem.Text
GetContactsFromCompanyForThisProject ()
End Sub
' THIS IS MY GETCOMPANYNAMES FUNCTION
Function GetCompanyNamesForThisProject() as DataSet
dsCompanyNames.Clear()
Dim strConnString As String = "JET OLEDB PROVIDER AND MDB FILE"
Dim queryString As String = "SELECT COMPANYNAMES FROM USERS WHERE
PROJECT = @dotnet.itags.org.PROJECT"
Dim dataAdapter As New OleDbDataAdapter (querystring, strConnString)
dataAdapter.Fill(dsCompanyNames, "users")
Return dsCompanyNames
End Function
' THIS IS MY GETCONTACTNAMES FUNCTION
Function GetContactsFromCompanyForThisProject () As DataSet
dsContacts.Clear()
Dim strConnString As String = "JET OLEDB PROVIDER AND PATH TO MDB FILE"
Response.Write("coName = " & coName)
Dim queryString As String
queryString = "SELECT [users].[name] FROM [users] WHERE
(([users].[cname] = '" & coName & "')" & " AND ([users].[project] = '" &
Session("project") & "'))"
' queryString = "SELECT [users].[name] FROM [users] WHERE
(([users]. [cname] = 'FDM') AND ([users].[project] = '" &
Session("project") & "'))"
Dim dataAdapter As New OleDbDataAdapter (querystring,
strConnString)
dataAdapter.Fill(dsContacts, "users")
Return dsContacts
End Function
In the GetContactsFromCompanyForThisProject function, I am able to hard code
a company name and successfully populate the second control but if I attempt
to pass the variable coName to the query string, it will not switch the
contact names for each company that is selected in the first control.
The controls are called out as follows:
<asp:DropDownList
id="ddlTo"
runat="server"
DataValueField="cname"
AutoPostBack="True"
DataSource='<%# GetCompanyNamesForThisProject() %>'
OnSelectedIndexChanged="ddlTo_SelectedIndexChanged"
/>
<asp:DropDownList
id="ddlContact"
runat="server"
DataValueField="name"
AutoPostBack="True"
DataSource='<%# GetContactsFromCompanyForThisProject() %>'
/>
Any replies would be extremely appreciated.Shouldn't it be'
querystring="SELECT * FROM USERS WHERE CNAME = '" & var & "'"
"glenn" <glenn@.discussions.microsoft.com> wrote in message
news:011A49D5-7D96-46B3-A953-BDA72CC829E4@.microsoft.com...
> Hi folks,
> The problem I have is that a query string works if hard-coded but
> if I pass a variable to it, it does not work as shown here.
> This works:
> querystring="SELECT * FROM USERS WHERE CNAME = 'MICROSOFT'"
> This does not work:
> Dim var as string
> var = "Microsoft"
> querystring="SELECT * FROM USERS WHERE CNAME = " & 'var'"
> I have 2 DropDownList controls.
> The first control is populated with a dataset of company names.
> The second control is populated with a dataset of contact names for
> the company that was selected in the first control.
> The first control has an OnSelectedIndexChanged event handler.
> The first control has a datasource set equal to a function named
> GetCompanyNames.
> The second control has a datasource set equal to a function named
> GetContactNames.
> In the OnSelectedIndexChanged event handler, I call the GetContactNames
> function to
> populate the second control with Contact Names that are associated with
> the
> Company
> Name selected in the first control.
> All is working well, but the Contact Names in the second control do not
> change as
> different companies are selected in the first control.
> What follows is a pseudo code description of my code:
> ' THESE ARE CALLED AS GLOBAL VARIABLES AT TOP OF THE PAGE
> Dim coName as string
> Dim dsCompanyNames as DataSet = New DataSet ( )
> Dim dsContacts as DataSet = New DataSet ()
> ' THIS IS MY OnSelectedIndexChanged EVENT HANDLER
> Sub ddlTo_SelectedIndexChanged(sender As Object, e As EventArgs)
> Dim list As DropDownList = CType(sender, DropDownList)
> coName=list.SelectedItem.Text
> GetContactsFromCompanyForThisProject ()
> End Sub
> ' THIS IS MY GETCOMPANYNAMES FUNCTION
> Function GetCompanyNamesForThisProject() as DataSet
> dsCompanyNames.Clear()
> Dim strConnString As String = "JET OLEDB PROVIDER AND MDB FILE"
> Dim queryString As String = "SELECT COMPANYNAMES FROM USERS WHERE
> PROJECT = @.PROJECT"
> Dim dataAdapter As New OleDbDataAdapter (querystring, strConnString)
> dataAdapter.Fill(dsCompanyNames, "users")
> Return dsCompanyNames
> End Function
> ' THIS IS MY GETCONTACTNAMES FUNCTION
> Function GetContactsFromCompanyForThisProject () As DataSet
> dsContacts.Clear()
> Dim strConnString As String = "JET OLEDB PROVIDER AND PATH TO MDB
> FILE"
> Response.Write("coName = " & coName)
> Dim queryString As String
> queryString = "SELECT [users].[name] FROM [users] WHERE
> (([users].[cname] = '" & coName & "')" & " AND ([users].[project] = '" &
> Session("project") & "'))"
> ' queryString = "SELECT [users].[name] FROM [users] WHERE
> (([users]. [cname] = 'FDM') AND ([users].[project] = '" &
> Session("project") & "'))"
> Dim dataAdapter As New OleDbDataAdapter (querystring,
> strConnString)
> dataAdapter.Fill(dsContacts, "users")
> Return dsContacts
> End Function
> In the GetContactsFromCompanyForThisProject function, I am able to hard
> code
> a company name and successfully populate the second control but if I
> attempt
> to pass the variable coName to the query string, it will not switch the
> contact names for each company that is selected in the first control.
> The controls are called out as follows:
> <asp:DropDownList
> id="ddlTo"
> runat="server"
> DataValueField="cname"
> AutoPostBack="True"
> DataSource='<%# GetCompanyNamesForThisProject() %>'
> OnSelectedIndexChanged="ddlTo_SelectedIndexChanged"
> />
> <asp:DropDownList
> id="ddlContact"
> runat="server"
> DataValueField="name"
> AutoPostBack="True"
> DataSource='<%# GetContactsFromCompanyForThisProject() %>'
> />
>
> Any replies would be extremely appreciated.
Yes, I am sorry. I wrote my pseudo code incorrectly. Your syntax
is the way my code actually reads if you follow down through my
question.
So, no it seems that it still does not work when a variable is passed.
I think it might be deeper than just the SQL statement so read on
if you can.
Thanks,
glenn
"ShaneFowlkes" wrote:

> Shouldn't it be'
> querystring="SELECT * FROM USERS WHERE CNAME = '" & var & "'"
>
>
> "glenn" <glenn@.discussions.microsoft.com> wrote in message
> news:011A49D5-7D96-46B3-A953-BDA72CC829E4@.microsoft.com...
>
>
Found what seemed to be in err in my SQL statement that passes a variable
but the change still did not work.
Here it is:
queryString = "SELECT [users].[name] FROM [users] WHERE
(([users].[cname] = '" & coName & "') AND ([users].[project] = '" &
Session("project") & "'))"
"glenn" wrote:
> Yes, I am sorry. I wrote my pseudo code incorrectly. Your syntax
> is the way my code actually reads if you follow down through my
> question.
> So, no it seems that it still does not work when a variable is passed.
> I think it might be deeper than just the SQL statement so read on
> if you can.
> Thanks,
> glenn
> "ShaneFowlkes" wrote:
>
It is bad practice to build your SQL queries this way as it leaves you code
vulnerable to SQL injection exploits. You should use parameters in your SQL
stament such as
"SELECT field1, field2, field3 from table1 where field3 = @.ParameterName"
"glenn" wrote:
> Found what seemed to be in err in my SQL statement that passes a variable
> but the change still did not work.
> Here it is:
> queryString = "SELECT [users].[name] FROM [users] WHERE
> (([users].[cname] = '" & coName & "') AND ([users].[project] = '" &
> Session("project") & "'))"
>
> "glenn" wrote:
>
Response.write your sql statement. We have no way of knowing the values of
your variables
Jeff
"glenn" <glenn@.discussions.microsoft.com> wrote in message
news:8F5639CE-660E-457B-A5F0-B01558358014@.microsoft.com...
> Found what seemed to be in err in my SQL statement that passes a variable
> but the change still did not work.
> Here it is:
> queryString = "SELECT [users].[name] FROM [users] WHERE
> (([users].[cname] = '" & coName & "') AND ([users].[project] = '" &
> Session("project") & "'))"
>
> "glenn" wrote:
>

Passing variable to SQL string is not working.

Hi folks,

The problem I have is that a query string works if hard-coded but
if I pass a variable to it, it does not work as shown here.

This works:
querystring="SELECT * FROM USERS WHERE CNAME = 'MICROSOFT'"

This does not work:
Dim var as string
var = "Microsoft"
querystring="SELECT * FROM USERS WHERE CNAME = " & 'var'"

I have 2 DropDownList controls.

The first control is populated with a dataset of company names.

The second control is populated with a dataset of contact names for
the company that was selected in the first control.

The first control has an OnSelectedIndexChanged event handler.

The first control has a datasource set equal to a function named
GetCompanyNames.

The second control has a datasource set equal to a function named
GetContactNames.

In the OnSelectedIndexChanged event handler, I call the GetContactNames
function to
populate the second control with Contact Names that are associated with the
Company
Name selected in the first control.

All is working well, but the Contact Names in the second control do not
change as
different companies are selected in the first control.

What follows is a pseudo code description of my code:

' THESE ARE CALLED AS GLOBAL VARIABLES AT TOP OF THE PAGE
Dim coName as string
Dim dsCompanyNames as DataSet = New DataSet ( )
Dim dsContacts as DataSet = New DataSet ()

' THIS IS MY OnSelectedIndexChanged EVENT HANDLER
Sub ddlTo_SelectedIndexChanged(sender As Object, e As EventArgs)
Dim list As DropDownList = CType(sender, DropDownList)
coName=list.SelectedItem.Text
GetContactsFromCompanyForThisProject ()
End Sub

' THIS IS MY GETCOMPANYNAMES FUNCTION
Function GetCompanyNamesForThisProject() as DataSet
dsCompanyNames.Clear()
Dim strConnString As String = "JET OLEDB PROVIDER AND MDB FILE"
Dim queryString As String = "SELECT COMPANYNAMES FROM USERS WHERE
PROJECT = @dotnet.itags.org.PROJECT"

Dim dataAdapter As New OleDbDataAdapter (querystring, strConnString)

dataAdapter.Fill(dsCompanyNames, "users")

Return dsCompanyNames
End Function

' THIS IS MY GETCONTACTNAMES FUNCTION
Function GetContactsFromCompanyForThisProject () As DataSet
dsContacts.Clear()
Dim strConnString As String = "JET OLEDB PROVIDER AND PATH TO MDB FILE"
Response.Write("coName = " & coName)

Dim queryString As String

queryString = "SELECT [users].[name] FROM [users] WHERE
(([users].[cname] = '" & coName & "')" & " AND ([users].[project] = '" &
Session("project") & "'))"

' queryString = "SELECT [users].[name] FROM [users] WHERE
(([users]. [cname] = 'FDM') AND ([users].[project] = '" &
Session("project") & "'))"

Dim dataAdapter As New OleDbDataAdapter (querystring,
strConnString)

dataAdapter.Fill(dsContacts, "users")

Return dsContacts
End Function

In the GetContactsFromCompanyForThisProject function, I am able to hard code
a company name and successfully populate the second control but if I attempt
to pass the variable coName to the query string, it will not switch the
contact names for each company that is selected in the first control.

The controls are called out as follows:
<asp:DropDownList
id="ddlTo"
runat="server"
DataValueField="cname"
AutoPostBack="True"
DataSource='<%# GetCompanyNamesForThisProject() %>'
OnSelectedIndexChanged="ddlTo_SelectedIndexChanged"
/
<asp:DropDownList
id="ddlContact"
runat="server"
DataValueField="name"
AutoPostBack="True"
DataSource='<%# GetContactsFromCompanyForThisProject() %>'
/
Any replies would be extremely appreciated.Shouldn't it be??

querystring="SELECT * FROM USERS WHERE CNAME = '" & var & "'"

"glenn" <glenn@.discussions.microsoft.com> wrote in message
news:011A49D5-7D96-46B3-A953-BDA72CC829E4@.microsoft.com...
> Hi folks,
> The problem I have is that a query string works if hard-coded but
> if I pass a variable to it, it does not work as shown here.
> This works:
> querystring="SELECT * FROM USERS WHERE CNAME = 'MICROSOFT'"
> This does not work:
> Dim var as string
> var = "Microsoft"
> querystring="SELECT * FROM USERS WHERE CNAME = " & 'var'"
> I have 2 DropDownList controls.
> The first control is populated with a dataset of company names.
> The second control is populated with a dataset of contact names for
> the company that was selected in the first control.
> The first control has an OnSelectedIndexChanged event handler.
> The first control has a datasource set equal to a function named
> GetCompanyNames.
> The second control has a datasource set equal to a function named
> GetContactNames.
> In the OnSelectedIndexChanged event handler, I call the GetContactNames
> function to
> populate the second control with Contact Names that are associated with
> the
> Company
> Name selected in the first control.
> All is working well, but the Contact Names in the second control do not
> change as
> different companies are selected in the first control.
> What follows is a pseudo code description of my code:
> ' THESE ARE CALLED AS GLOBAL VARIABLES AT TOP OF THE PAGE
> Dim coName as string
> Dim dsCompanyNames as DataSet = New DataSet ( )
> Dim dsContacts as DataSet = New DataSet ()
> ' THIS IS MY OnSelectedIndexChanged EVENT HANDLER
> Sub ddlTo_SelectedIndexChanged(sender As Object, e As EventArgs)
> Dim list As DropDownList = CType(sender, DropDownList)
> coName=list.SelectedItem.Text
> GetContactsFromCompanyForThisProject ()
> End Sub
> ' THIS IS MY GETCOMPANYNAMES FUNCTION
> Function GetCompanyNamesForThisProject() as DataSet
> dsCompanyNames.Clear()
> Dim strConnString As String = "JET OLEDB PROVIDER AND MDB FILE"
> Dim queryString As String = "SELECT COMPANYNAMES FROM USERS WHERE
> PROJECT = @.PROJECT"
> Dim dataAdapter As New OleDbDataAdapter (querystring, strConnString)
> dataAdapter.Fill(dsCompanyNames, "users")
> Return dsCompanyNames
> End Function
> ' THIS IS MY GETCONTACTNAMES FUNCTION
> Function GetContactsFromCompanyForThisProject () As DataSet
> dsContacts.Clear()
> Dim strConnString As String = "JET OLEDB PROVIDER AND PATH TO MDB
> FILE"
> Response.Write("coName = " & coName)
> Dim queryString As String
> queryString = "SELECT [users].[name] FROM [users] WHERE
> (([users].[cname] = '" & coName & "')" & " AND ([users].[project] = '" &
> Session("project") & "'))"
> ' queryString = "SELECT [users].[name] FROM [users] WHERE
> (([users]. [cname] = 'FDM') AND ([users].[project] = '" &
> Session("project") & "'))"
> Dim dataAdapter As New OleDbDataAdapter (querystring,
> strConnString)
> dataAdapter.Fill(dsContacts, "users")
> Return dsContacts
> End Function
> In the GetContactsFromCompanyForThisProject function, I am able to hard
> code
> a company name and successfully populate the second control but if I
> attempt
> to pass the variable coName to the query string, it will not switch the
> contact names for each company that is selected in the first control.
> The controls are called out as follows:
> <asp:DropDownList
> id="ddlTo"
> runat="server"
> DataValueField="cname"
> AutoPostBack="True"
> DataSource='<%# GetCompanyNamesForThisProject() %>'
> OnSelectedIndexChanged="ddlTo_SelectedIndexChanged"
> />
> <asp:DropDownList
> id="ddlContact"
> runat="server"
> DataValueField="name"
> AutoPostBack="True"
> DataSource='<%# GetContactsFromCompanyForThisProject() %>'
> />
>
> Any replies would be extremely appreciated.
Yes, I am sorry. I wrote my pseudo code incorrectly. Your syntax
is the way my code actually reads if you follow down through my
question.

So, no it seems that it still does not work when a variable is passed.
I think it might be deeper than just the SQL statement so read on
if you can.

Thanks,
glenn

"ShaneFowlkes" wrote:

> Shouldn't it be??
> querystring="SELECT * FROM USERS WHERE CNAME = '" & var & "'"
>
>
> "glenn" <glenn@.discussions.microsoft.com> wrote in message
> news:011A49D5-7D96-46B3-A953-BDA72CC829E4@.microsoft.com...
> > Hi folks,
> > The problem I have is that a query string works if hard-coded but
> > if I pass a variable to it, it does not work as shown here.
> > This works:
> > querystring="SELECT * FROM USERS WHERE CNAME = 'MICROSOFT'"
> > This does not work:
> > Dim var as string
> > var = "Microsoft"
> > querystring="SELECT * FROM USERS WHERE CNAME = " & 'var'"
> > I have 2 DropDownList controls.
> > The first control is populated with a dataset of company names.
> > The second control is populated with a dataset of contact names for
> > the company that was selected in the first control.
> > The first control has an OnSelectedIndexChanged event handler.
> > The first control has a datasource set equal to a function named
> > GetCompanyNames.
> > The second control has a datasource set equal to a function named
> > GetContactNames.
> > In the OnSelectedIndexChanged event handler, I call the GetContactNames
> > function to
> > populate the second control with Contact Names that are associated with
> > the
> > Company
> > Name selected in the first control.
> > All is working well, but the Contact Names in the second control do not
> > change as
> > different companies are selected in the first control.
> > What follows is a pseudo code description of my code:
> > ' THESE ARE CALLED AS GLOBAL VARIABLES AT TOP OF THE PAGE
> > Dim coName as string
> > Dim dsCompanyNames as DataSet = New DataSet ( )
> > Dim dsContacts as DataSet = New DataSet ()
> > ' THIS IS MY OnSelectedIndexChanged EVENT HANDLER
> > Sub ddlTo_SelectedIndexChanged(sender As Object, e As EventArgs)
> > Dim list As DropDownList = CType(sender, DropDownList)
> > coName=list.SelectedItem.Text
> > GetContactsFromCompanyForThisProject ()
> > End Sub
> > ' THIS IS MY GETCOMPANYNAMES FUNCTION
> > Function GetCompanyNamesForThisProject() as DataSet
> > dsCompanyNames.Clear()
> > Dim strConnString As String = "JET OLEDB PROVIDER AND MDB FILE"
> > Dim queryString As String = "SELECT COMPANYNAMES FROM USERS WHERE
> > PROJECT = @.PROJECT"
> > Dim dataAdapter As New OleDbDataAdapter (querystring, strConnString)
> > dataAdapter.Fill(dsCompanyNames, "users")
> > Return dsCompanyNames
> > End Function
> > ' THIS IS MY GETCONTACTNAMES FUNCTION
> > Function GetContactsFromCompanyForThisProject () As DataSet
> > dsContacts.Clear()
> > Dim strConnString As String = "JET OLEDB PROVIDER AND PATH TO MDB
> > FILE"
> > Response.Write("coName = " & coName)
> > Dim queryString As String
> > queryString = "SELECT [users].[name] FROM [users] WHERE
> > (([users].[cname] = '" & coName & "')" & " AND ([users].[project] = '" &
> > Session("project") & "'))"
> > ' queryString = "SELECT [users].[name] FROM [users] WHERE
> > (([users]. [cname] = 'FDM') AND ([users].[project] = '" &
> > Session("project") & "'))"
> > Dim dataAdapter As New OleDbDataAdapter (querystring,
> > strConnString)
> > dataAdapter.Fill(dsContacts, "users")
> > Return dsContacts
> > End Function
> > In the GetContactsFromCompanyForThisProject function, I am able to hard
> > code
> > a company name and successfully populate the second control but if I
> > attempt
> > to pass the variable coName to the query string, it will not switch the
> > contact names for each company that is selected in the first control.
> > The controls are called out as follows:
> > <asp:DropDownList
> > id="ddlTo"
> > runat="server"
> > DataValueField="cname"
> > AutoPostBack="True"
> > DataSource='<%# GetCompanyNamesForThisProject() %>'
> > OnSelectedIndexChanged="ddlTo_SelectedIndexChanged"
> > />
> > <asp:DropDownList
> > id="ddlContact"
> > runat="server"
> > DataValueField="name"
> > AutoPostBack="True"
> > DataSource='<%# GetContactsFromCompanyForThisProject() %>'
> > />
> > Any replies would be extremely appreciated.
>
Found what seemed to be in err in my SQL statement that passes a variable
but the change still did not work.

Here it is:
queryString = "SELECT [users].[name] FROM [users] WHERE
(([users].[cname] = '" & coName & "') AND ([users].[project] = '" &
Session("project") & "'))"

"glenn" wrote:

> Yes, I am sorry. I wrote my pseudo code incorrectly. Your syntax
> is the way my code actually reads if you follow down through my
> question.
> So, no it seems that it still does not work when a variable is passed.
> I think it might be deeper than just the SQL statement so read on
> if you can.
> Thanks,
> glenn
> "ShaneFowlkes" wrote:
> > Shouldn't it be??
> > querystring="SELECT * FROM USERS WHERE CNAME = '" & var & "'"
> > "glenn" <glenn@.discussions.microsoft.com> wrote in message
> > news:011A49D5-7D96-46B3-A953-BDA72CC829E4@.microsoft.com...
> > > Hi folks,
> > > > The problem I have is that a query string works if hard-coded but
> > > if I pass a variable to it, it does not work as shown here.
> > > > This works:
> > > querystring="SELECT * FROM USERS WHERE CNAME = 'MICROSOFT'"
> > > > This does not work:
> > > Dim var as string
> > > var = "Microsoft"
> > > querystring="SELECT * FROM USERS WHERE CNAME = " & 'var'"
> > > > I have 2 DropDownList controls.
> > > > The first control is populated with a dataset of company names.
> > > > The second control is populated with a dataset of contact names for
> > > the company that was selected in the first control.
> > > > The first control has an OnSelectedIndexChanged event handler.
> > > > The first control has a datasource set equal to a function named
> > > GetCompanyNames.
> > > > The second control has a datasource set equal to a function named
> > > GetContactNames.
> > > > In the OnSelectedIndexChanged event handler, I call the GetContactNames
> > > function to
> > > populate the second control with Contact Names that are associated with
> > > the
> > > Company
> > > Name selected in the first control.
> > > > All is working well, but the Contact Names in the second control do not
> > > change as
> > > different companies are selected in the first control.
> > > > What follows is a pseudo code description of my code:
> > > > ' THESE ARE CALLED AS GLOBAL VARIABLES AT TOP OF THE PAGE
> > > Dim coName as string
> > > Dim dsCompanyNames as DataSet = New DataSet ( )
> > > Dim dsContacts as DataSet = New DataSet ()
> > > > ' THIS IS MY OnSelectedIndexChanged EVENT HANDLER
> > > Sub ddlTo_SelectedIndexChanged(sender As Object, e As EventArgs)
> > > Dim list As DropDownList = CType(sender, DropDownList)
> > > coName=list.SelectedItem.Text
> > > GetContactsFromCompanyForThisProject ()
> > > End Sub
> > > > ' THIS IS MY GETCOMPANYNAMES FUNCTION
> > > Function GetCompanyNamesForThisProject() as DataSet
> > > dsCompanyNames.Clear()
> > > Dim strConnString As String = "JET OLEDB PROVIDER AND MDB FILE"
> > > Dim queryString As String = "SELECT COMPANYNAMES FROM USERS WHERE
> > > PROJECT = @.PROJECT"
> > > > Dim dataAdapter As New OleDbDataAdapter (querystring, strConnString)
> > > > dataAdapter.Fill(dsCompanyNames, "users")
> > > > Return dsCompanyNames
> > > End Function
> > > > ' THIS IS MY GETCONTACTNAMES FUNCTION
> > > Function GetContactsFromCompanyForThisProject () As DataSet
> > > dsContacts.Clear()
> > > Dim strConnString As String = "JET OLEDB PROVIDER AND PATH TO MDB
> > > FILE"
> > > Response.Write("coName = " & coName)
> > > > Dim queryString As String
> > > > queryString = "SELECT [users].[name] FROM [users] WHERE
> > > (([users].[cname] = '" & coName & "')" & " AND ([users].[project] = '" &
> > > Session("project") & "'))"
> > > > ' queryString = "SELECT [users].[name] FROM [users] WHERE
> > > (([users]. [cname] = 'FDM') AND ([users].[project] = '" &
> > > Session("project") & "'))"
> > > > Dim dataAdapter As New OleDbDataAdapter (querystring,
> > > strConnString)
> > > > dataAdapter.Fill(dsContacts, "users")
> > > > Return dsContacts
> > > End Function
> > > > In the GetContactsFromCompanyForThisProject function, I am able to hard
> > > code
> > > a company name and successfully populate the second control but if I
> > > attempt
> > > to pass the variable coName to the query string, it will not switch the
> > > contact names for each company that is selected in the first control.
> > > > The controls are called out as follows:
> > > <asp:DropDownList
> > > id="ddlTo"
> > > runat="server"
> > > DataValueField="cname"
> > > AutoPostBack="True"
> > > DataSource='<%# GetCompanyNamesForThisProject() %>'
> > > OnSelectedIndexChanged="ddlTo_SelectedIndexChanged"
> > > />
> > > > <asp:DropDownList
> > > id="ddlContact"
> > > runat="server"
> > > DataValueField="name"
> > > AutoPostBack="True"
> > > DataSource='<%# GetContactsFromCompanyForThisProject() %>'
> > > />
> > > > > Any replies would be extremely appreciated.
It is bad practice to build your SQL queries this way as it leaves you code
vulnerable to SQL injection exploits. You should use parameters in your SQL
stament such as

"SELECT field1, field2, field3 from table1 where field3 = @.ParameterName"

"glenn" wrote:

> Found what seemed to be in err in my SQL statement that passes a variable
> but the change still did not work.
> Here it is:
> queryString = "SELECT [users].[name] FROM [users] WHERE
> (([users].[cname] = '" & coName & "') AND ([users].[project] = '" &
> Session("project") & "'))"
>
> "glenn" wrote:
> > Yes, I am sorry. I wrote my pseudo code incorrectly. Your syntax
> > is the way my code actually reads if you follow down through my
> > question.
> > So, no it seems that it still does not work when a variable is passed.
> > I think it might be deeper than just the SQL statement so read on
> > if you can.
> > Thanks,
> > glenn
> > "ShaneFowlkes" wrote:
> > > Shouldn't it be??
> > > > querystring="SELECT * FROM USERS WHERE CNAME = '" & var & "'"
> > > > > > > "glenn" <glenn@.discussions.microsoft.com> wrote in message
> > > news:011A49D5-7D96-46B3-A953-BDA72CC829E4@.microsoft.com...
> > > > Hi folks,
> > > > > > The problem I have is that a query string works if hard-coded but
> > > > if I pass a variable to it, it does not work as shown here.
> > > > > > This works:
> > > > querystring="SELECT * FROM USERS WHERE CNAME = 'MICROSOFT'"
> > > > > > This does not work:
> > > > Dim var as string
> > > > var = "Microsoft"
> > > > querystring="SELECT * FROM USERS WHERE CNAME = " & 'var'"
> > > > > > I have 2 DropDownList controls.
> > > > > > The first control is populated with a dataset of company names.
> > > > > > The second control is populated with a dataset of contact names for
> > > > the company that was selected in the first control.
> > > > > > The first control has an OnSelectedIndexChanged event handler.
> > > > > > The first control has a datasource set equal to a function named
> > > > GetCompanyNames.
> > > > > > The second control has a datasource set equal to a function named
> > > > GetContactNames.
> > > > > > In the OnSelectedIndexChanged event handler, I call the GetContactNames
> > > > function to
> > > > populate the second control with Contact Names that are associated with
> > > > the
> > > > Company
> > > > Name selected in the first control.
> > > > > > All is working well, but the Contact Names in the second control do not
> > > > change as
> > > > different companies are selected in the first control.
> > > > > > What follows is a pseudo code description of my code:
> > > > > > ' THESE ARE CALLED AS GLOBAL VARIABLES AT TOP OF THE PAGE
> > > > Dim coName as string
> > > > Dim dsCompanyNames as DataSet = New DataSet ( )
> > > > Dim dsContacts as DataSet = New DataSet ()
> > > > > > ' THIS IS MY OnSelectedIndexChanged EVENT HANDLER
> > > > Sub ddlTo_SelectedIndexChanged(sender As Object, e As EventArgs)
> > > > Dim list As DropDownList = CType(sender, DropDownList)
> > > > coName=list.SelectedItem.Text
> > > > GetContactsFromCompanyForThisProject ()
> > > > End Sub
> > > > > > ' THIS IS MY GETCOMPANYNAMES FUNCTION
> > > > Function GetCompanyNamesForThisProject() as DataSet
> > > > dsCompanyNames.Clear()
> > > > Dim strConnString As String = "JET OLEDB PROVIDER AND MDB FILE"
> > > > Dim queryString As String = "SELECT COMPANYNAMES FROM USERS WHERE
> > > > PROJECT = @.PROJECT"
> > > > > > Dim dataAdapter As New OleDbDataAdapter (querystring, strConnString)
> > > > > > dataAdapter.Fill(dsCompanyNames, "users")
> > > > > > Return dsCompanyNames
> > > > End Function
> > > > > > ' THIS IS MY GETCONTACTNAMES FUNCTION
> > > > Function GetContactsFromCompanyForThisProject () As DataSet
> > > > dsContacts.Clear()
> > > > Dim strConnString As String = "JET OLEDB PROVIDER AND PATH TO MDB
> > > > FILE"
> > > > Response.Write("coName = " & coName)
> > > > > > Dim queryString As String
> > > > > > queryString = "SELECT [users].[name] FROM [users] WHERE
> > > > (([users].[cname] = '" & coName & "')" & " AND ([users].[project] = '" &
> > > > Session("project") & "'))"
> > > > > > ' queryString = "SELECT [users].[name] FROM [users] WHERE
> > > > (([users]. [cname] = 'FDM') AND ([users].[project] = '" &
> > > > Session("project") & "'))"
> > > > > > Dim dataAdapter As New OleDbDataAdapter (querystring,
> > > > strConnString)
> > > > > > dataAdapter.Fill(dsContacts, "users")
> > > > > > Return dsContacts
> > > > End Function
> > > > > > In the GetContactsFromCompanyForThisProject function, I am able to hard
> > > > code
> > > > a company name and successfully populate the second control but if I
> > > > attempt
> > > > to pass the variable coName to the query string, it will not switch the
> > > > contact names for each company that is selected in the first control.
> > > > > > The controls are called out as follows:
> > > > <asp:DropDownList
> > > > id="ddlTo"
> > > > runat="server"
> > > > DataValueField="cname"
> > > > AutoPostBack="True"
> > > > DataSource='<%# GetCompanyNamesForThisProject() %>'
> > > > OnSelectedIndexChanged="ddlTo_SelectedIndexChanged"
> > > > />
> > > > > > <asp:DropDownList
> > > > id="ddlContact"
> > > > runat="server"
> > > > DataValueField="name"
> > > > AutoPostBack="True"
> > > > DataSource='<%# GetContactsFromCompanyForThisProject() %>'
> > > > />
> > > > > > > > Any replies would be extremely appreciated.
> > >
Response.write your sql statement. We have no way of knowing the values of
your variables

Jeff
"glenn" <glenn@.discussions.microsoft.com> wrote in message
news:8F5639CE-660E-457B-A5F0-B01558358014@.microsoft.com...
> Found what seemed to be in err in my SQL statement that passes a variable
> but the change still did not work.
> Here it is:
> queryString = "SELECT [users].[name] FROM [users] WHERE
> (([users].[cname] = '" & coName & "') AND ([users].[project] = '" &
> Session("project") & "'))"
>
> "glenn" wrote:
>> Yes, I am sorry. I wrote my pseudo code incorrectly. Your syntax
>> is the way my code actually reads if you follow down through my
>> question.
>>
>> So, no it seems that it still does not work when a variable is passed.
>> I think it might be deeper than just the SQL statement so read on
>> if you can.
>>
>> Thanks,
>> glenn
>>
>> "ShaneFowlkes" wrote:
>>
>> > Shouldn't it be??
>>> > querystring="SELECT * FROM USERS WHERE CNAME = '" & var & "'"
>>>>>> > "glenn" <glenn@.discussions.microsoft.com> wrote in message
>> > news:011A49D5-7D96-46B3-A953-BDA72CC829E4@.microsoft.com...
>> > > Hi folks,
>> >> > > The problem I have is that a query string works if hard-coded but
>> > > if I pass a variable to it, it does not work as shown here.
>> >> > > This works:
>> > > querystring="SELECT * FROM USERS WHERE CNAME = 'MICROSOFT'"
>> >> > > This does not work:
>> > > Dim var as string
>> > > var = "Microsoft"
>> > > querystring="SELECT * FROM USERS WHERE CNAME = " & 'var'"
>> >> > > I have 2 DropDownList controls.
>> >> > > The first control is populated with a dataset of company names.
>> >> > > The second control is populated with a dataset of contact names for
>> > > the company that was selected in the first control.
>> >> > > The first control has an OnSelectedIndexChanged event handler.
>> >> > > The first control has a datasource set equal to a function named
>> > > GetCompanyNames.
>> >> > > The second control has a datasource set equal to a function named
>> > > GetContactNames.
>> >> > > In the OnSelectedIndexChanged event handler, I call the
>> > > GetContactNames
>> > > function to
>> > > populate the second control with Contact Names that are associated
>> > > with
>> > > the
>> > > Company
>> > > Name selected in the first control.
>> >> > > All is working well, but the Contact Names in the second control do
>> > > not
>> > > change as
>> > > different companies are selected in the first control.
>> >> > > What follows is a pseudo code description of my code:
>> >> > > ' THESE ARE CALLED AS GLOBAL VARIABLES AT TOP OF THE PAGE
>> > > Dim coName as string
>> > > Dim dsCompanyNames as DataSet = New DataSet ( )
>> > > Dim dsContacts as DataSet = New DataSet ()
>> >> > > ' THIS IS MY OnSelectedIndexChanged EVENT HANDLER
>> > > Sub ddlTo_SelectedIndexChanged(sender As Object, e As EventArgs)
>> > > Dim list As DropDownList = CType(sender, DropDownList)
>> > > coName=list.SelectedItem.Text
>> > > GetContactsFromCompanyForThisProject ()
>> > > End Sub
>> >> > > ' THIS IS MY GETCOMPANYNAMES FUNCTION
>> > > Function GetCompanyNamesForThisProject() as DataSet
>> > > dsCompanyNames.Clear()
>> > > Dim strConnString As String = "JET OLEDB PROVIDER AND MDB FILE"
>> > > Dim queryString As String = "SELECT COMPANYNAMES FROM USERS
>> > > WHERE
>> > > PROJECT = @.PROJECT"
>> >> > > Dim dataAdapter As New OleDbDataAdapter (querystring,
>> > > strConnString)
>> >> > > dataAdapter.Fill(dsCompanyNames, "users")
>> >> > > Return dsCompanyNames
>> > > End Function
>> >> > > ' THIS IS MY GETCONTACTNAMES FUNCTION
>> > > Function GetContactsFromCompanyForThisProject () As DataSet
>> > > dsContacts.Clear()
>> > > Dim strConnString As String = "JET OLEDB PROVIDER AND PATH TO
>> > > MDB
>> > > FILE"
>> > > Response.Write("coName = " & coName)
>> >> > > Dim queryString As String
>> >> > > queryString = "SELECT [users].[name] FROM [users] WHERE
>> > > (([users].[cname] = '" & coName & "')" & " AND ([users].[project] =
>> > > '" &
>> > > Session("project") & "'))"
>> >> > > ' queryString = "SELECT [users].[name] FROM [users] WHERE
>> > > (([users]. [cname] = 'FDM') AND ([users].[project] = '" &
>> > > Session("project") & "'))"
>> >> > > Dim dataAdapter As New OleDbDataAdapter (querystring,
>> > > strConnString)
>> >> > > dataAdapter.Fill(dsContacts, "users")
>> >> > > Return dsContacts
>> > > End Function
>> >> > > In the GetContactsFromCompanyForThisProject function, I am able to
>> > > hard
>> > > code
>> > > a company name and successfully populate the second control but if I
>> > > attempt
>> > > to pass the variable coName to the query string, it will not switch
>> > > the
>> > > contact names for each company that is selected in the first control.
>> >> > > The controls are called out as follows:
>> > > <asp:DropDownList
>> > > id="ddlTo"
>> > > runat="server"
>> > > DataValueField="cname"
>> > > AutoPostBack="True"
>> > > DataSource='<%# GetCompanyNamesForThisProject() %>'
>> > > OnSelectedIndexChanged="ddlTo_SelectedIndexChanged"
>> > > />
>> >> > > <asp:DropDownList
>> > > id="ddlContact"
>> > > runat="server"
>> > > DataValueField="name"
>> > > AutoPostBack="True"
>> > > DataSource='<%# GetContactsFromCompanyForThisProject() %>'
>> > > />
>> >> >> > > Any replies would be extremely appreciated.
>>>

Wednesday, March 21, 2012

Passing variables in query string in the HyperLinkColumn of a datagrid

Hi All,
I have to pass variable in a query string.
The query string is in the hyperlink coloumn of a datgrid.
The code appears like this
<asp:HyperLinkColumn DataNavigateUrlField="ProductID"
DataNavigateUrlFormatString="ViewProduct.aspx?qProductID='<%strProduct%>'"
DataTextField="ProductID" HeaderText="Product ID">
<HeaderStyle Width="10%"></HeaderStyle>
</asp:HyperLinkColumn>
this does not work..
Can any one help..Where is <%strProduct%>' coming from. Is this a column in your datasource.
If so then you need to sue the binding synthax '<%# strProduct%>'
TDAVISJR
aka - Tampa.NET Koder
<aparnasinha26@.yahoo.com> wrote in message
news:1116325678.716477.36020@.z14g2000cwz.googlegroups.com...
> Hi All,
> I have to pass variable in a query string.
> The query string is in the hyperlink coloumn of a datgrid.
> The code appears like this
> <asp:HyperLinkColumn DataNavigateUrlField="ProductID"
> DataNavigateUrlFormatString="ViewProduct.aspx?qProductID='<%strProduct%>'"
> DataTextField="ProductID" HeaderText="Product ID">
> <HeaderStyle Width="10%"></HeaderStyle>
> </asp:HyperLinkColumn>
>
> this does not work..
> Can any one help..
>
Hi,
Thanks..
To continue with ur question..
No '<%=ADstrProduct%>' is a variable which stores the value from a query
string.
The page is accepting a query string which is stored in query string
'qProduct'
I assign qProduct to the public variable strProduct on form load in my
code behind file of asp.net.
the code behind is VB ie I am working on VB.Net.
I hope this clears your question

Passing variables in query string in the HyperLinkColumn of a datagrid

Hi All,
I have to pass variable in a query string.
The query string is in the hyperlink coloumn of a datgrid.

The code appears like this
<asp:HyperLinkColumn DataNavigateUrlField="ProductID"
DataNavigateUrlFormatString="ViewProduct.aspx?qProductID='<%strProduct%>'"
DataTextField="ProductID" HeaderText="Product ID">
<HeaderStyle Width="10%"></HeaderStyle>
</asp:HyperLinkColumn
this does not work..
Can any one help..Where is <%strProduct%>' coming from. Is this a column in your datasource.
If so then you need to sue the binding synthax '<%# strProduct%>'

--
TDAVISJR
aka - Tampa.NET Koder

<aparnasinha26@.yahoo.com> wrote in message
news:1116325678.716477.36020@.z14g2000cwz.googlegro ups.com...
> Hi All,
> I have to pass variable in a query string.
> The query string is in the hyperlink coloumn of a datgrid.
> The code appears like this
> <asp:HyperLinkColumn DataNavigateUrlField="ProductID"
> DataNavigateUrlFormatString="ViewProduct.aspx?qProductID='<%strProduct%>'"
> DataTextField="ProductID" HeaderText="Product ID">
> <HeaderStyle Width="10%"></HeaderStyle>
> </asp:HyperLinkColumn>
>
> this does not work..
> Can any one help..
Hi,
Thanks..
To continue with ur question..
No '<%*strProduct%>' is a variable which stores the value from a query
string.
The page is accepting a query string which is stored in query string
'qProduct'
I assign qProduct to the public variable strProduct on form load in my
code behind file of asp.net.
the code behind is VB ie I am working on VB.Net.

I hope this clears your question

passing variables to new aspx page using hyperlink column from a datagrid

I am trying to get the value of the hyperlink column to the second aspx page to use it in a sql query. I have it passing to the new page. I don't know how to get/receive it in the new page. Any help would be appreciated.

<Columns>
<asp:TemplateColumn ><ItemTemplate>
<asp:HyperLink runat="Server" NavigateUrl='<%# "../IPDP/ViewObjective.aspx?PlanID=" & DataBinder.Eval(Container.DataItem, "IPDP_PLAN_ID") & "&ObjID=" & DataBinder.Eval(Container.DataItem, "IPDP_OBJ_ID")%>' Text="VIEW" ID="hyperObj"/>
</asp:HyperLink></ItemTemplate></asp:TemplateColumn

example on other page request("PlanID")
Maybe I'm misunderstanding you. This is what I have and the error it's giving me.

From page1:
<asp:TemplateColumn HeaderText="Select Ticket">
<ItemTemplate>
<asp:HyperLink id="HyperLink1" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Number")%>' NavigateUrl='<%# "ticketsearch_db2a.aspx?Number=" & DataBinder.Eval(Container, "DataItem.Number")%>' />
</ItemTemplate>
</asp:TemplateColumn
On page2:

Dim TicNumber as string
TicNumber = request("Number")
Dim vNumber as String
Dim vName as String
Dim vDtissue as String
Dim vrace as String
Dim vsex as String
Dim vDlNum as String
Dim voffcode as String
Dim vspact as String
Dim vsppost as String
Dim vDtCourt as String
Dim vCity as String
Dim vStreet as String
Dim vCitype as String
Dim vCourt as String
Dim strConn as string = "server='sma18'; user id='sdasch'; password='ilovemynewhouse'; database='bluegrass"& _
"'"
Sub DoQuery(Source as Object, E as EventArgs)

Dim MySQL as string = "SELECT [Tickets].* FROM [Tickets] WHERE [Tickets].[number] = '" & TicNumber & "'"
Dim MyConn as New SQLConnection(strConn)
Dim ds as DataSet=New DataSet()
Dim Cmd as New SQLDataAdapter(MySQL,MyConn)
Cmd.Fill(ds,"Tickets")

'These lines assign the data to a variable, which is then assigned to the text property of a literal control(litEmps)
Dim dr As DataRow
For Each dr In ds.Tables("Tickets").Rows
vNumber+=dr("vnumber")
vName+=dr("first") & " " & dr("middle") & " " & dr("last") & " " & dr("suffix")
vDtissue+=dr("dtissue")
vrace+=dr("race")
vsex+=dr("sex")
vDlNum+=dr("dlnum")
voffcode+=dr("offcode")
vspact+=dr("spact")
vsppost+=dr("sppost")
vDtcourt+=dr("dtcourt")
vCity+=dr("city")
vStreet+=dr("street")
vCitype+=dr("citype")
vcourt+=dr("court")
Next
number1.text=vNumber
name1.text=vName
dtissue1.text=vdtissue
race1.text=vrace
sex1.text=vsex
DlNum1.text=vdlnum
offcode1.text=voffcode
spact1.text=vspact
sppost1.text=vsppost
Dtcourt1.text=vdtcourt
Street1.text=vstreet

Error:
Compiler Error Message: BC30188: Declaration expected.

Line 7: Dim TicNumber as string
Line 8: TicNumber = request("Number")
you can try Request.QueryString.Get("Number") for line 8
Thanks for trying. That gives me the same error.

I have <%=Request("Number")%> in the HTML portion of the code and that seems to give me the Number printed on the screen. I just need to figure out how to get it into a variable to use in the sql statement.

If you have any other ideas, I would appreciate them.

Again, Thanks for your help.

Follow this logic...

Function getRequestID()
Dim ID as INTEGER
ID = Request.QueryString("ID")
return ID
END FUNCTION

Where Function is called...
Page.aspx?ID=<%=getRequestID()%>