Re: Putting the Drop Down value in a variable

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I generally write a function that makes a call to the database and grabs the
name associated to the id:

public function GetNAmeFromId(ByVal Id as integer) as string

Dim sql as String
Din cnstr as String

sql = "Select SiteName from Sites where Site_Id =" & Id
connection code and the rest go here

GetNameFrom Id = Rs.Fields("SiteName").Value

Close rs from here and set rs = nothing


End Function


"Rohan Kapoor" <RohanKapoor@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:B9281BAE-BEC1-4C0C-B8B1-BE3DFC285AE6@xxxxxxxxxxxxxxxx
Hi,

I posted a question before and it really helped me to progress in my
project. Now I'm stuck again :( but this time it is a much simpler issue
than
before. I have a total of 4 drop downs which are interconnected with each
other. Each drop down is connected with a datasource which is pulling 3
columns from a table and is displaying only 1 of them (as it is a text
column
that is displayed in the DD and is connected with an ID value column).
I am looking to assign the Text value chosen in the drop down in the
variable. By default the variable is getting the ID value of the selected
field but I want the Text value/other column value.
Sitename = Site.SelectedValue where Sitename is the variable, Site is the
drop down. This is giving me the Site ID but I want the Site name.
Also this DD is bound by a DataSource selecting 3 fields from the Site
table
and the drop down's DataTextField is SiteName and DataValueField is
SiteId.

I would really appreciate your reply.

Thanks,

Rohan



.



Relevant Pages

  • Re: Setting up a database class and parameters
    ... but the connection can be used by only one instance ... > Public Sub New(ByVal ConnectionString As String) ... > Public Function Execute(ByVal SQL As String) As Integer ... > Public Function ExecuteStoredProcAs Integer ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Setting up a database class and parameters
    ... "William Vaughn" wrote in message ... In my New function, I am setting up a new connection, aren't I? ... >> Public Sub New(ByVal ConnectionString As String) ... >> Public Function ExecuteStoredProcAs Integer ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: passing a connection object into a sub ByVal
    ... >Public Function RunSQLSelect(ByVal dbConn As ADODB.Connection, ByVal sSQL As ... >String) As ADODB.Recordset ... >What is the affect of passing a connection object in ByVal. ...
    (microsoft.public.vb.database.ado)
  • Re: Setting up a database class and parameters
    ... The following is open to SQL injection attacks if you aren't careful: ... > ' and makes a connection to that SQL Server. ... > Public Sub New(ByVal ConnectionString As String) ... > Public Function ExecuteStoredProcAs Integer ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: converting the use of interfaces under vb6 to vb.net
    ... VB6. ... | Public Function NewEnum() As IUnknown ... |> Public Interface IReadonlyPerson ... |> | Public Property Get FirstNameas String ...
    (microsoft.public.dotnet.languages.vb)