How to use a TextBox for different SQL Server operations?

0

I am using WebForms, for the platform that is already working correctly in the work, in conjunction with VB.NET, I have a question on how to work with a single text field, and, in turn, the same Text field can work to store different information in the database.

I have my SQL Server table like the following

CREATE TABLE TblUser(
    UserID INT IDENTITY(1,1) PRIMARY KEY,
    UserName varchar(50),
    UserLastName varchar(50),
    UserAge INT,
    UserPhone varchar(50),
    UserEmail varchar(50),
    UserCreated_at DateTime,
    UserUpdated_at DateTime 
)

The main idea is to be able to use a single text field for all the fields. You can use a one-dimensional array and so, after filling the array proceed to save the information in the Database.

In the following image

What is he going to do?

In the Label "Enter name:", you will save the user's name, then the Label will appear "Enter Last Name:" and the TextBox will allow you to save the Last Name, and it will be successively.

Only, I do not know how to perform the operations to achieve the expected result.

Here is the VB.NET code

Frontend

<asp:Label ID="lblChange" runat="server" Text="Ingrese nombre:"></asp:Label>
<asp:TextBox ID="txtChange" runat="server" Width="190px"></asp:TextBox>

Backend

Imports System.Data
Partial Class userRegister
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        txtChange.Focus()
    End Sub
    Protected Sub txtChange_TextChanged(sender As Object, e As System.EventArgs) Handles txtChange.TextChanged

    End Sub
End Class
    
asked by Alan Amaury Escobedo García 28.09.2018 в 21:58
source

2 answers

0

This does not think it solves your problem but I do not think you can do it that way, I've done something similar but it's the exact length I need, however the names and surnames do not have a defined length, I think it would be better to do a form with many TextBox or do it with MsgBox

Sorry I came up with a way but you will have to use a button, you can store the status of what you are doing and from there see what action will be executed

Example (pseudocodigo):

variable estado = "nombre" (string)
if(estado == "nombre") {
   label.text = "nombre"
}else if(estado == "apellidos"){
  label.text = "apellidos"
}

You will have to change the value of "state" when you press the button if you press the button and the status is "name" that the state changes to "surnames", if you do not understand tell me and I can do a more explained example.

    
answered by 28.09.2018 в 23:43
0

Why do not you create the entire object of your table and then play with the attribute "visible"?

you put two buttons "Back" and "Next": and in the events of the buttons and settings

MyControl.Style["Visibility"] = "visible";

You can also create a combobox with the names of the fields in the table and enter the respective information in the textbox.

But better create all the necessary controls to save the information.

Greetings

    
answered by 29.09.2018 в 01:05