Home Python Store the value of a textbox

Store the value of a textbox

ASP.NET is an application framework which can be used to combine other applications such as VB, SQL databases to create dynamic and interactive web pages. One such example is to create a textbox using Visual Basic framework to gather the user's input. The value entered by the user in the textbox can be saved to databases like SQL, which can be used dynamically for other parts of the program. This not only provides the programmer the flexibility to pass a value dynamically but also engages the user in a more visual manner by showing nice graphic options such as a textbox, listbox or combobox.

Hello... I'm a new user of aset... I'm creating an aset webpage using VB code. I wanted to know how to store the textbox value (input from user) into the SQL database table...

I need a sample code for this. I'm using ASP.NET 3.5, Visual Studio 2008, and SQL server 2005.

If the html page has the textboxes where the user will input his/her data, then the user has to click on submit after filling the form. Here is a sample code for you.

html code :





aset code : Imports System.Data Imports System.Data.SqlClient Partial Class _Default Inherits System.Web.UI.Page Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click 'assigning string with values of textbox. Dim strName, strPlace As String strName = TextBox1.Text strPlace = TextBox2.Text 'declaring sql connection. please complete it by urself Dim sqlcon As New SqlConnection("server=;database=;uid=;password=") 'checking if connection is open. if open close it and open again. If sqlcon.State = ConnectionState.Open Then sqlcon.Close() End If sqlcon.Open() Dim strcommand As String 'the insert command is stored in strcommand 'Table Name : Contact 'Column of table : Name, Place strcommand = "Insert into Contact(Name,Place) values ('" + strName + "','" + strPlace + "')" Dim sqlcomm As New SqlCommand(strcommand, sqlcon) Dim o As String = sqlcomm.ExecuteNonQuery() label3ext = "Entry Added!" End Sub End Class

Solved by jennifer

  • Python

LEAVE A REPLY

Please enter your comment!
Please enter your name!