تو دات نت 2 برای بدست آوردن ID رکوردی که الان وارد کردیم چیکار باید بکنیم
کدی که نوشتم اینه
Dim conDB As SqlConnection
Dim cmdAddarticle As SqlCommand
Dim parmArticleID As SqlParameter
Dim variable as integer
conDB = New SqlConnection("server=.;uid=sa;pwd=;database=article_db")
cmdAddarticle = New SqlCommand("SP_InsertArticle", conDB)
cmdAddarticle.CommandType = commandtype.storedprocedure
parmArticleID = cmdAddarticle.Parameters.Add("returnvalue", SqlDbType.BigInt)
parmArticleID.Direction = ParameterDirection.ReturnValue
If txtKeyWords.Text.ToString <> "" Then
cmdAddarticle.Parameters.Add("@KeyWords", SqlDbType.NVarChar).Value = txtKeyWords.Text.ToString
Else
cmdAddarticle.Parameters.Add("@KeyWords", SqlDbType.NVarChar).Value = ""
End If
conDB.Open()
cmdAddarticle.ExecuteNonQuery()
variable = cmdAddarticle.Parameters("returnvalue").Value
conDB.Close()
کدی که نوشتم اینه
Dim conDB As SqlConnection
Dim cmdAddarticle As SqlCommand
Dim parmArticleID As SqlParameter
Dim variable as integer
conDB = New SqlConnection("server=.;uid=sa;pwd=;database=article_db")
cmdAddarticle = New SqlCommand("SP_InsertArticle", conDB)
cmdAddarticle.CommandType = commandtype.storedprocedure
parmArticleID = cmdAddarticle.Parameters.Add("returnvalue", SqlDbType.BigInt)
parmArticleID.Direction = ParameterDirection.ReturnValue
If txtKeyWords.Text.ToString <> "" Then
cmdAddarticle.Parameters.Add("@KeyWords", SqlDbType.NVarChar).Value = txtKeyWords.Text.ToString
Else
cmdAddarticle.Parameters.Add("@KeyWords", SqlDbType.NVarChar).Value = ""
End If
conDB.Open()
cmdAddarticle.ExecuteNonQuery()
variable = cmdAddarticle.Parameters("returnvalue").Value
conDB.Close()