Hello community I have a question regarding how to make the form push to the database and insert the data provided in the table what happens is that according to me I already have the correct insert and I need to run it so that when I enter the section of new User asks me to fill out a form but when I try to enter that section I get the following: **System.Data.SqlClient.SqlException: 'The parameterized query '(@UserN nvarchar(4000),@Password nvarchar(4000),@Role nvarchar(4' expects the parameter '@UserN', which was not supplied.' ** from what I read of the error it tells me that it is waiting for the parameter but it never receives something which does not happen because it does not even load the view according to my theory is that it loads the controller before the view loads and does not let me do the process correctly then I would like to know how I can make this not happen I would like that this function of insert in the table would happen after all the data is filled inside the form I do not know if the onclick() event also works in VB I leave my code to know what is wrong
Dim Nombre As String
Dim Puesto As String
Dim role As String
' Obtener los valores del formulario
UserN = Request.Form("userN")
password = Request.Form("password")
role = Request.Form("Role")
Nombre = Request.Form("Nombre")
Puesto = Request.Form("Puesto")
' Query para insertar los valores en la base de datos
Dim query As String = "INSERT INTO IntranetSecurity (UserN, Password, Role, Nombre, Puesto) VALUES (@UserN, @Password, @Role, @Nombre, @Puesto)"
Using command As New SqlCommand(query, cnn)
' Agregar parámetros para prevenir inyección SQL y asegurar la integridad de los datos
command.Parameters.AddWithValue("@UserN", UserN)
command.Parameters.AddWithValue("@Password", password)
command.Parameters.AddWithValue("@Role", role)
command.Parameters.AddWithValue("@Nombre", Nombre)
command.Parameters.AddWithValue("@Puesto", Puesto)
' Abrir la conexión y ejecutar el comando
cnn.Open()
command.ExecuteNonQuery()
End Using
Return View()```
ExecuteNonQuery, which would be well after you should have entered the data. I'm also not sure why you would be usingRequest.Formin a controller action. Why haven't you got a model with the appropriate properties?