how to declare variables in vb.net and store variable data in sql server

        Using connection As New SqlConnection("Data Source=(local)\SQLEXPRESS;Integrated Security=True;Initial Catalog=tempdb;")
            connection.Open()

            Dim command As New SqlCommand(
                "UPDATE tblSAMP SET fieldSAMP1 = @fieldSAMP1, @fieldSAMP2 = fieldSAMP2 WHERE fieldSAMP3 = @fieldSAMP3",
                connection)
            ' assign input parameters
            command.Parameters.AddWithValue("@fieldSAMP1", 999)
            command.Parameters.AddWithValue("@fieldSAMP3", 9090909)

            ' output parameter was @decSamp
            Dim fieldSAMP2Parameter = command.Parameters.Add(
                New SqlParameter("@fieldSAMP2", SqlDbType.Int) With {.Direction = ParameterDirection.Output})

            ' if the query modified one row at least
            If command.ExecuteNonQuery() > 0 Then
                ' get the output parameter(s)
                Dim decSamp As Integer = CInt(fieldSAMP2Parameter.Value)
            End If
        End Using

Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source