RE:conexion de bd y txtbox
El codigo seria el siguiente:
Dim Coneccion As Data.SqlClient.SqlConnection
Coneccion = New SqlConnection("server=DESARROLLO;database=Nombre Base de Datos;Trusted_Connection=yes")
SqlTxt = "SELECT SUM(cantidad) AS SUMA_TOTAL FROM PARTICIPACIONES_REGALOS where codigo=@codigo GROUP BY codigo"
Dim Comando As Data.SqlClient.SqlCommand
Comando = New SqlCommand(SqlTxt, Coneccion)
Comando.Parameters.Add("@codigo", SqlDbType.Int)
Comando.Parameters("@codigo").Value = lblcodigo.Text
Coneccion.Open()
Dim dr As SqlDataReader
dr = Comando.ExecuteReader
If dr.HasRows Then
While dr.Read()
Label1.Text = (dr("SUMA_TOTAL").ToString())
End While
End If
Coneccion.Close()
dr.Close()