Не могли бы вы помочь мне с этим утверждением, я пытаюсь получить данные с помощью инструкции SELECT и использовать дату в инструкции INSERT
.Использование оператора Select для значения ведомости вставки
Я хочу использовать данные, полученные для ProfileId
Значение.
// Get the UserId of the just-added user
MembershipUser currentUser = Membership.GetUser();
Guid currentUserId = (Guid)currentUser.ProviderUserKey;
// Insert a new record into UserPro
string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
string insertSql = "INSERT INTO User_Friend(ProfileId1, ProfileId) VALUES(@FriendProfileId) SELECT ProfileId FROM User_Profile WHERE UserId = (@UserId)";
using (SqlConnection myConnection = new SqlConnection(connectionString))
{
myConnection.Open();
SqlCommand myCommand = new SqlCommand(insertSql, myConnection);
myCommand.Parameters.AddWithValue("@FriendProfileId", Request.QueryString["ProfileId"].ToString());
myCommand.Parameters.AddWithValue("@UserId", currentUserId);
myCommand.ExecuteNonQuery();
myConnection.Close();
}
Как использовать SELECT
результат как ProfileId
Value.
Возможный дубликат [t-sql insert - select - with parameters] (http://stackoverflow.com/questions/11996549/t-sql-insert-select-with-parameters) – BCdotWEB