Código:
Imports System.Data
Imports System.Data.SqlClient
Public Class Form4
Dim user As Integer
Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Conexion As New SqlConnection(conectar("EVE\SQLEXPRESS", "pollo"))
Dim sql1 As String = "Select * from numusuarios"
Dim DE As New SqlDataAdapter(sql1, Conexion)
Dim Dg As New DataSet
DE.Fill(Dg, "numusuarios")
Dim fila As DataRow
fila = Dg.Tables("numusuarios").Rows(0)
user = fila("numero")
Dim user1
user1 = user
user = user + 1
Dim adapter1 As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter("proceso1", Conexion)
Dim asd1 As DataTable = New DataTable()
Dim sql As String = "UPDATE numusuarios SET numero=@NOMBRE where numero=@numeroas"
Dim cmd As New SqlCommand(sql, Conexion)
adapter1.SelectCommand.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add("@NOMBRE", SqlDbType.Int).Value = user '
adapter1.SelectCommand.Parameters.Add(New SqlClient.SqlParameter("@NOMBRE", user))
adapter1.SelectCommand.Parameters.Add(New SqlClient.SqlParameter("@numeroas", user1))
Dim adapter As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter("proceso2", Conexion)
Dim asd As DataTable = New DataTable()
adapter.SelectCommand.CommandType = CommandType.StoredProcedure
adapter.SelectCommand.Parameters.Add(New SqlClient.SqlParameter("@clave", user))
adapter.SelectCommand.Parameters.Add(New SqlClient.SqlParameter("@usuario", Me.TextBox1.Text))
adapter.SelectCommand.Parameters.Add(New SqlClient.SqlParameter("@contra", Me.TextBox2.Text))
adapter.Fill(asd)
adapter.Dispose()
MessageBox.Show("registro guardado")
End Sub
Private Function conectar(ByVal servidorsql As String, ByVal basedatos As String) As String
Dim cnn As String
cnn = "data source = '" & servidorsql & "'; initial catalog = '" & basedatos & "'; INTEGRATED SECURITY = TRUE "
Return cnn
End Function
End Class
en el caso de ese codigo el registro que quiero modificar es para llevar la cuenta de los usuarios que estan registrados espero y me puedan ayudar...gracias.