473,408 Members | 2,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

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 = @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.
Apr 21 '06 #1
5 1812
Shouldn't it be??

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


"glenn" <gl***@discussions.microsoft.com> wrote in message
news:01**********************************@microsof t.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.

Apr 21 '06 #2
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" <gl***@discussions.microsoft.com> wrote in message
news:01**********************************@microsof t.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.


Apr 21 '06 #3
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" <gl***@discussions.microsoft.com> wrote in message
news:01**********************************@microsof t.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.


Apr 21 '06 #4
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" <gl***@discussions.microsoft.com> wrote in message
news:01**********************************@microsof t.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.

Apr 21 '06 #5
Response.write your sql statement. We have no way of knowing the values of
your variables

Jeff
"glenn" <gl***@discussions.microsoft.com> wrote in message
news:8F**********************************@microsof t.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" <gl***@discussions.microsoft.com> wrote in message
> news:01**********************************@microsof t.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.
>
>
>

Apr 21 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
39
by: Mike MacSween | last post by:
Just spent a happy 10 mins trying to understand a function I wrote sometime ago. Then remembered that arguments are passed by reference, by default. Does the fact that this slowed me down...
17
by: LP | last post by:
Hello, Here's the scenario: Object A opens a Sql Db connection to execute number of SqlCommands. Then it needs to pass this connection to a constructor of object B which in turn executes more...
6
by: Scott Zabolotzky | last post by:
I'm trying to pass a custom object back and forth between forms. This custom object is pulled into the app using an external reference to an assembly DLL that was given to me by a co-worker. A...
3
by: James Robertson | last post by:
I am new to the ASP and VB thing so be kind. Question I have is that I have created an ASPX web site to use as an E-Mail page. But I want to use this for a lot of users. Can I create the link on...
11
by: kennthompson | last post by:
Trouble passing mysql table name in php. If I use an existing table name already defined everything works fine as the following script illustrates. <?php function fms_get_info() { $result =...
5
by: moni | last post by:
Hi.. I am trying to use javascript for google maps display. If I call the javascript function from my aspx file I use: <input type="text" id="addresstext" value="Huntington Avenue,...
11
by: =?Utf-8?B?U3VqZWV0?= | last post by:
If there are long strings (like 1MB or 2MB) is it more performant to pass those by ref to methods or by value?
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.