Sorry, I didn't read far enough.
Replace UserID.Text with Name.Text
"Jared" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> This assumes you have an asp:textbox on the form.
> If it isn't a server-side control you can do can access it using
> CType(FindControl("ControlID"), ControlType).PropertyToAccess
> For example - with a DropDownList:
> Dim MyValue As String = CType(Me.FindControl("DropDownList1"),
> DropDownList).SelectedValue
> - or -
> DropDownList1.SelectedValue
>
> Be careful when you do this, an attacker can use sql injection to delete
> your database, or worse.
> Sub SubmitBtn_Click(Sender As Object, E As EventArgs)
>
> Dim DS As DataSet
> Dim MyConnection As SqlConnection
> Dim MyCommand As SqlDataAdapter
>
> MyConnection = New
> SqlConnection("server=wfsnt62;database=SecurityInfo;User
> Id=sa;Password=wfssa62;Trusted_Connection=False")
> MyCommand = New SqlDataAdapter("select UserName, roleName, DBName,
> Title, EmpNo, " _
> & "CostCenter from UserInfo where MSName = '" & UserID.Text & "'",
> myConnection)
>
> End Sub
>
> "rondebbs" <(E-Mail Removed)> wrote in message
> news:ED4798D4-0E8E-4491-932A-(E-Mail Removed)...
>> Hello, below is my first attempt at programming (actually copying someone
>> elses script and modifying it for my needs). My sql statement is hard
>> coded
>> with -
>> where MSName = 'br17348'. I really want the where clause to use the value
>> in
>> the User ID field. How do I dynamically pick up the value entered in User
>> ID
>> of this page for my query? I have not been able to get the syntax
>> correct.
>>
>> Thanks - Brad
>>
>> <%@ Import Namespace="System.Data" %>
>> <%@ Import Namespace="System.Data.SqlClient" %>
>>
>> <html>
>> <head>
>> <link rel="stylesheet"href="intro.css">
>> </head>
>>
>> <script language="VB" runat=server>
>>
>> Sub SubmitBtn_Click(Sender As Object, E As EventArgs)
>>
>> Dim DS As DataSet
>> Dim MyConnection As SqlConnection
>> Dim MyCommand As SqlDataAdapter
>>
>> MyConnection = New
>> SqlConnection("server=wfsnt62;database=SecurityInfo;User
>> Id=sa;Password=wfssa62;Trusted_Connection=False")
>> MyCommand = New SqlDataAdapter("select UserName, roleName, DBName, Title,
>> EmpNo, CostCenter from UserInfo where MSName = 'br17348'", myConnection)
>>
>>
>>
>> DS = new DataSet()
>> MyCommand.Fill(DS, "UserInfo")
>>
>> MyList.DataSource = DS.Tables("UserInfo").DefaultView
>> MyList.DataBind()
>>
>> End Sub
>>
>>
>> </script>
>>
>> <body>
>>
>> <center>
>>
>> <form action="Brad.aspx" method="post" runat="server">
>>
>> <h3> User Id: <asp:textbox id="Name" runat="server"/>
>>
>>
>> </h3>
>>
>> <asp:button text="Lookup" OnClick="SubmitBtn_Click" runat="server"/>
>>
>> <p>
>>
>> <ASPataGrid id="MyList" HeaderStyle-BackColor="#aaaadd"
>> BackColor="#ccccff"
>> runat="server"/>
>>
>> </form>
>>
>> </center>
>>
>> </body>
>>
>> </html>
>>
>
>
|