 |
|
|
variable escalar
tema iniciado porpeyin en Visual Basic .NET
Mensaje recibido el [15/10/2008 11:24:08]
tengo un codigo en un boton guardar el que tengo el siguiente codigo
Private Sub Guardar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Guardar.Click
If txtid.Text = " " Then
MsgBox( "debe digitar una identificacion")
txtid.Focus()
Exit Sub
Else
conectar()
Dim sqla As String = "SELECT Identificacion From empleados " + _
" Where Identificacion = " & txtid.Text.ToUpper & " "
Dim t As SqlCommand = New SqlCommand(sqla, con)
Dim s As SqlDataReader = t.ExecuteReader()
If Not s.HasRows Then
t.Connection.Close()
s.Close()
Dim resp As Integer
resp = MsgBox( " ¿desea guardar el usuario?", MsgBoxStyle.YesNo + MsgBoxStyle.DefaultButton2 + MsgBoxStyle.Question, " Alerta")
If resp = vbYes Then
conectar()
Dim cmd As New SqlCommand
cmd.CommandType = System.Data.CommandType.Text
cmd.CommandText = ( "insert into empleados (Identificacion,nombreempleado,primerapellido,segundoapellido,direccion,telefono,celular,imail,sexo,cargo,estado,nombrecentrocosto) values ( @Identificacion,@nombreempleado,@primerapellido,@segundoapellido,@direccion,@telefono,@celular,@imail,@sexo,@cargo,@estado,@nombrecentocosto,")
cmd.Parameters.Add( New SqlParameter("@Identificacion", SqlDbType.NVarChar)).Value = txtid.Text
cmd.Connection = con
cmd.ExecuteNonQuery()
cmd.CommandType = System.Data.CommandType.Text
cmd.Parameters.Add( New SqlParameter("@nombreempleado", SqlDbType.NVarChar)).Value = txtnom.Text
cmd.Connection = con
cmd.ExecuteNonQuery()
cmd.CommandType = System.Data.CommandType.Text
cmd.Parameters.Add( New SqlParameter("@primerapellido", SqlDbType.NVarChar)).Value = txtpa.Text
cmd.Connection = con
cmd.ExecuteNonQuery()
cmd.CommandType = System.Data.CommandType.Text
cmd.Parameters.Add( New SqlParameter("@segundoapellido", SqlDbType.NVarChar)).Value = txtsa.Text
cmd.Connection = con
cmd.ExecuteNonQuery()
cmd.CommandType = System.Data.CommandType.Text
cmd.Parameters.Add( New SqlParameter("@direccion", SqlDbType.NVarChar)).Value = txtdir.Text
cmd.Connection = con
cmd.ExecuteNonQuery()
cmd.CommandType = System.Data.CommandType.Text
cmd.Parameters.Add( New SqlParameter("@telefono", SqlDbType.NVarChar)).Value = txttel.Text
cmd.Connection = con
cmd.ExecuteNonQuery()
cmd.CommandType = System.Data.CommandType.Text
cmd.Parameters.Add( New SqlParameter("@celular", SqlDbType.NVarChar)).Value = txtcel.Text
cmd.Connection = con
cmd.ExecuteNonQuery()
cmd.CommandType = System.Data.CommandType.Text
cmd.Parameters.Add( New SqlParameter("@imail", SqlDbType.NVarChar)).Value = txtimail.Text
cmd.Connection = con
cmd.ExecuteNonQuery()
cmd.CommandType = System.Data.CommandType.Text
cmd.Parameters.Add( New SqlParameter("@sexo", SqlDbType.NVarChar)).Value = sexo.ToUpper
cmd.Connection = con
cmd.ExecuteNonQuery()
cmd.CommandType = System.Data.CommandType.Text
cmd.Parameters.Add( New SqlParameter("@cargo", SqlDbType.NVarChar)).Value = cargo.ToUpper
cmd.Connection = con
cmd.ExecuteNonQuery()
cmd.CommandType = System.Data.CommandType.Text
cmd.Parameters.Add( New SqlParameter("@estado", SqlDbType.NVarChar)).Value = estado.ToUpper
cmd.Connection = con
cmd.ExecuteNonQuery()
cmd.CommandType = System.Data.CommandType.Text
cmd.Parameters.Add( New SqlParameter("@nombrecentrocosto", SqlDbType.NVarChar)).Value = seccion.ToUpper
cmd.Connection = con
cmd.ExecuteNonQuery()
el problema esta que cuando lo ejecuto me sale este error una linea en amarillo en cmd.executenonquery y luego me sale un mensaje que dice
: Must declare the scalar variable "@nombreempleado".
debe declarar la variable escalar "@nombreempleado" quiero que me hagan el favor y me ayuden a saber que tengo que hacer , que es una variable escalar? y como la declaro? es pero que me ayuden gracias
|
 |
| Encuesta |
|
¿A que perfil te adaptas mejor? |
|
|
|
|
|
|
|
|
|