
Mostrar datos en un textbox
Publicado por Brand (5 intervenciones) el 21/03/2016 19:44:42
Hola de nuevo a todos, esta vez tengo un inconveniente al querer mostrar una sola columna de mi base de datos SQL SERVER en un textbox porfavor si me pueden dar una manito
esto es de mi boton guardar pero quiero mostrar el maximo valor del id_deposito en un textbox y no lo consigo hacer porfavor si me pueden dar una ayuda gracias
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Private Sub btn_guardar_Click(sender As Object, e As EventArgs) Handles btn_guardar.Click
Dim b As Integer
Dim sConnectionString As String _
= "Data Source=localhost;Initial Catalog=Trisys;Integrated Security=True"
Dim objConn As New SqlConnection(sConnectionString)
objConn.Open()
Dim objCmd As New SqlCommand
objCmd.CommandType = CommandType.Text
If txt_cant.Text = "" Or txt_cod.Text = "" Or txt_descripcion.Text = "" Then
MsgBox("LLENE TODOS LOS CAMPOS", 0 + 16, "ERROR DE CARGA DE DATOS")
Exit Sub
End If
objCmd.CommandText = "DECLARE @id_deposito int; select @id_deposito = max(id_deposito) + 1 from deposito;
INSERT INTO deposito (id_deposito,nombre,ubicacion,cantidad,codigo,unid_medida,fechaent,origen)
VALUES (@id_deposito,@descripcion,@ubicacion,@cantidad,@codigo,@medida,@Fechaent,@Origen)"
objCmd.Parameters.Add("@Descripcion", SqlDbType.VarChar).Value = txt_descripcion.Text
objCmd.Parameters.Add("@Ubicacion", SqlDbType.VarChar).Value = cmb_ubicacion.SelectedValue
objCmd.Parameters.Add("@Cantidad", SqlDbType.Int).Value = Convert.ToInt64(txt_cant.Text)
objCmd.Parameters.Add("@Codigo", SqlDbType.VarChar).Value = txt_cod.Text
objCmd.Parameters.Add("@Medida", SqlDbType.VarChar).Value = cmb_medida.SelectedItem
objCmd.Parameters.Add("@Fechaent", SqlDbType.DateTime2).Value = txt_fechaent.Text
objCmd.Parameters.Add("@Origen", SqlDbType.VarChar).Value = txt_origen.Text
objCmd.Connection = objConn
Try
b = objCmd.ExecuteNonQuery()
If b > 0 Then
MessageBox.Show("DATOS GUARDADOS ")
End If
Catch q As Exception
MessageBox.Show(q.Message, "Error")
Finally
objConn.Close()
End Try
End Sub
esto es de mi boton guardar pero quiero mostrar el maximo valor del id_deposito en un textbox y no lo consigo hacer porfavor si me pueden dar una ayuda gracias
Valora esta pregunta


0