Showing posts with label button. Show all posts
Showing posts with label button. Show all posts

Wednesday, March 19, 2008

Telnet

Windows comes with a Telnet client. Although Windows XP does not come with a Telnet server application, you can add this functionality by installing Services for Unix (SFU version 3). SFU can be installed on Windows NT, 2000, 2003, and XP. So, for those who operate a small LAN, you can install a Telnet server on Windows XP Professional, along with many other Unix utilities and commands, for a small fee.

Windows XP, which has now been available for about five years, has gone through two major service packs and is now widely replacing older Windows 2000, Windows NT 4.0, and Windows 9x clients.

Tip

If you're considering an upgrade to Windows Server 2003, you might want to wait before jumping onto the bandwagon. When any new major version of an operating system is released, there are problems. This is inevitable due to the complexity of writing code for an operating system, much less performing extensive beta testing for a wide variety of applications. It's best to wait until at least the first service pack is released. It's also a good idea to subscribe to the many Windows/Unix/Linux newsgroups so that you can find out about features/bugs early adopters are experiencing.

Internet 2010

Server versions of Windows NT, 2000, and 2003 do provide a Telnet service, but it isn't enabled by default. You must have the TCP/IP protocol networking components installed in order to use the server. This can be done during the system installation or by using the Components button in the Add/Remove Software Control Panel utility. To start the service on a Windows Server 2003 computer, use the following steps:

Note

Click Start, All Programs, Administrative Tools, and then Services. A list of services available on the computer is displayed in the right pane.

Scroll down in the right pane until you find the Telnet service.

Right-click on the Telnet service and select Properties (or just double-click on the Telnet service).

From the General properties tab you can select how you want to start the Telnet service. The drop-down menu labeled Startup Type enables you to select Automatic (start when the system is booted), Manual (start the service when you want to use it), or Disabled (to prevent the Telnet service from being used). In this example, the Automatic option has been selected.

If you've selected either Automatic or Manual to start the service, you must start the service by clicking on the Start button. If you have chosen the Manual option, then you can close the dialog box and then re-open it and start the service when you wish by using the Start button. If you've chosen the Automatic option, the service will automatically start the next time you reboot the server. Notice also that there are Stop/Pause and Resume buttons on this General tab. The Start and Stop buttons do exactly what they say: They stop and start the service. However, if you use the Pause button, administrators and members of the Server Operators group can still use the service and establish a Telnet connection with the server. This can be useful when you don't want ordinary users making Telnet connections to the machine while you're performing maintenance chores, for example. Use the Resume button to allow the service to continue servicing other users (provided you haven't stopped the service).

Tip

If one or more of the options (start, stop, pause, and so on) appear grayed out (unavailable), it's because the current state of the Telnet server does not enable you to make the selection. For example, if the Telnet service has already been started, the Start button will not be available. Similarly, if the service is stopped, the Stop button will be grayed out and not available.

Tuesday, November 20, 2007

Deleting SQL Server Data, ASP.net

If you have code on your ASP.NET pages that allows visitors to enter a record, or where you add records through code without their input, you will likely need to delete records from your pages. This technique shows you how to use a SQL Delete query to delete records from an SQL Server table.

This technique displays a list of employees from an SQL Server table called Employees. Visitors select a name and then click the button. When they do that the employee selected is deleted from the database.

Defined on the page is this DropDownList control that will display the employee names:

dropdownlist id="ddlEmps" datatextfield="EmpName" datavaluefield="EmpID" runat="server"

Internet 2010and this Button control is defined:

button
id="butDelete" text="Delete" onclick="SubmitBtn_Click"
runat="server"
/ >

When the page first loads, the following code will populate the DropDownList control:

Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
If Not IsPostBack Then
Dim DBConn as SQLConnection
Dim DBCommand As SQLDataAdapter Dim DSPageData as New DataSet
DBConn = New SQLConnection("server=localhost;" _
& "Initial Catalog=TT;" _
& "User Id=sa;" _
"Password=yourpassword;") DBCommand = New SQLDataAdapter _ ("Select LastName + ' + FirstName "
& "as EmpName, EmpID " _
& "From Employees " _
& "Order By LastName, FirstName", DBConn)
DBCommand.Fill(DSPageData, _ "Employees")
ddlEmps.DataSource = _
DSPageData.Tables("Employees").DefaultView
ddlEmps.DataBind()
End If
End Sub

and this procedure fires when the Button control is clicked:

Sub SubmitBtn_Click(Sender As Object, E As EventArgs)

When that happens, you need a Connection and a Command object:

Dim DBConn as SQLConnection Dim DBDelete As New SQLCommand

You start by connecting to the SQL Server database:

DBConn = New SQLConnection("server=localhost;"
& "Initial Catalog=TT;" _
& "User Id=sa;"
"Password=yourpassword;")

Then the SQL Delete statement that will delete the record selected in the DropDownList control is placed into the CommandText property of the Command object:

DBDelete.CommandText = "Delete From Employees " _
& "Where EmpID = " & ddlEmps.SelectedItem.Value

The connection to the database for the Command object is made though the Connection object:

DBDelete.Connection = DBConn DBDelete.Connection.Open

and the offending record is deleted:

DBDelete.ExecuteNonQuery()

Monday, November 19, 2007

Adding SQL Server Data, ASP.net

When your ASP.NET application includes SQL Server database connectivity, you often will need to add records to the database through your ASP.NET pages. For example, you may track visitors as they visit your site. With each page they visit, you may want to add a hit record to your database. Or you may allow visitors to sign themselves up for a mailing list. In that case you would need to add their information to a database. This technique shows you how to add a record to an SQL Server database table.

Internet 2010

The ASP.NET page presented with this technique allows visitors to add an employee record to the SQL Server database. Visitors enter information into the provided TextBox controls and click the Button control to add the new record to the database.

Defined on the page are TextBox controls like this one used to enter the new information through:

<asp:textbox
id="txtLastName" runat="Server"

This Button control allows visitors to submit their request:

<asp:button
id="butOK"
text=" OK "
onclick="SubmitEtn_Click" runat="server"
/>

When that button is clicked, this procedure fires:

Sub SubmitBtn_Click(Sender As Object, E As EventArgs) To add a record, you will need a Connection object:

Dim DBConn as SQLConnection

and a Command object:

Dim DBAdd As New SQLCommand

The Connection object connects to the SQL Server database:

DBConn = New SQLConnection("server=localhost;" _
& "Initial Catalog=TT;" _
& "User Id=sa;" _
& "Password=yourpassword;")

Next, you place into the CommandText property of the Command object the SQL Insert statement that adds the new record:

DBAdd.CommandText = "Insert Into Employees (" _
& "LastName, FirstName, BirthDate, Salary, " _
& "EmailAddress) values (" _
& "'" & Replace(txtLastName.Text, "'", """) _
& "', "
* "'" Replace(txtFirstName.Text, "'", """)
&
* "'" Replace(txtBirthDate.Text, "'", """)
&
Replace- (txtSalary.Text, "'", """) & ", " _
& "'" & Replace(txtEmailAddress.Text, "'", """) _
& “.).

The Command object will connect to the database through the Connection object: DBAdd.Connection = DBConn

That connection is opened:

DBAdd.Connection.Open

and the record is added to the database:

DBAdd.ExecuteNonQuery()

Internet Blogosphere