none
HOW TO PASSED OUTPUT PARAMETER TO OTHER PARAMETER .. RRS feed

  • Question

  • tHIS is my code

     

    Using Con As New SqlConnection(My.Settings.sample)

     

    Dim A As Integer = 1

     

    Dim cmd As SqlCommand = New SqlCommand()

     

    Dim cmd1 As SqlCommand = New SqlCommand()

    cmd.CommandText =

    "AddNo"

    cmd.CommandType = CommandType.StoredProcedure

    cmd.Connection = Con

    cmd1.CommandText =

    "Addkartu"

    cmd1.CommandType = CommandType.StoredProcedure

    cmd1.Connection = Con

    cmd.Parameters.Add(

    "@nama", SqlDbType.NVarChar, 50)

    cmd.Parameters.Item(

    "@nama").Value = TextBox1.Text

    cmd.Parameters.Add(

    "@alamat", SqlDbType.NVarChar, 50)

    cmd.Parameters.Item(

    "@alamat").Value = TextBox2.Text

    cmd.Parameters.Add(

    "@pekerjaan", SqlDbType.NVarChar, 50)

    cmd.Parameters.Item(

    "@pekerjaan").Value = TextBox3.Text

    cmd.Parameters.Add(

    "@nokartu", SqlDbType.Int)

    cmd.Parameters.Item(

    "@NOKARTU").Direction = ParameterDirection.Output  -- this can use for other parameter ?

     

    cmd1.Parameters.Add(

    "@nokartu", SqlDbType.Int)-- i want use they parameter at here but i still got 0 value or 1 ..

    cmd1.Parameters.Item(

    "@NOKARTU").Value = icurenrow

     

    cmd1.Parameters.Add(

    "@jeniskartu", SqlDbType.NVarChar, 50)

    cmd1.Parameters.Item(

    "@jeniskartu").Value = TextBox4.Text

    cmd1.Parameters.Add(

    "@tahun", SqlDbType.NVarChar, 50)

    cmd1.Parameters.Item(

    "@tahun").Value = TextBox5.Text

    Con.Open()

    cmd.ExecuteScalar()

    cmd1.ExecuteScalar()

    Con.Close()

     

    Plzzz help with this problem.. thanks alot..

     

    Monday, October 11, 2010 7:01 PM

Answers

  • You can't in the same call. But you can modify the stored procedure....

    Miha Markic [MVP C#] http://blog.rthand.com
    • Marked as answer by liurong luo Friday, October 15, 2010 3:20 AM
    Tuesday, October 12, 2010 6:41 AM