01/04/2009 Development / asp.net

Exemplo fácil e rápido !!!!

        Dim con As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("Conexao").ConnectionString())
        Dim sql As SqlCommand = New SqlCommand("Insert into table ( campo1, campo2 ) Values ( 'valor1','valor2' ) select @@identity", con)

        Dim codID As Integer

        con.Open()
        codID = sql.ExecuteScalar()

        lblResultado.Text = "Shoooow de Boleta !!!"

Obs: select @@identity [ recupera o valor baseado na chave primária ]