hi,

i'm having troube with the SCOPE_IDENTITY of a Client-side SQL INSERT statement, it is returning '6' everytime which i think has something to do with the variable type 6 for Floating, not the actual value?

I'm really confused and can't seem to get it to return the actual value!

Please see the code below.

Code:
Dim SQLtext, a As String       

        a = Me.PurchaseDetailsTableAdapter.Connection.ConnectionString.Clone()
        Dim myCon As New SqlClient.SqlConnection(a)

        SQLtext = "INSERT INTO Purchases (CNum, CustomerID) " & _
           "VALUES(@par1, @par2) SELECT SCOPE_IDENTITY() AS NewID"

        Dim myCom As New SqlClient.SqlCommand(SQLtext, myCon)
       
        Dim val1 = "C1239"                          'ConNum
        Dim val2 = 1                                'CustomerID

        myCom.Parameters.Add(New SqlClient.SqlParameter("@par1", SqlDbType.VarChar)).Value = val1
        myCom.Parameters.Add(New SqlClient.SqlParameter("@par2", SqlDbType.Int)).Value = val2
        myCom.Parameters.Add(New SqlClient.SqlParameter("NewID", ParameterDirection.ReturnValue))

        myCon.Open()
        myCom.ExecuteNonQuery()
        Dim i = myCom.Parameters("NewID").Value
        Me.TextBox1.Text = i
        MsgBox("added")
        myCon.Close()

it is returning i = 6 (everytime) which is the value of the variable type Floating. How can i get it to return the actual value?

Thanks

Jon