我在 asp.net 网络表单中编码。我有默认从asp.net生成的用户表我需要获取当前的UserId,在我的情况下默认是uniqueidentifier
string user = User.Identity.Name; //this give me the name
string name = TextBoxCategoryName.Text;
this.connection.Open();
command = connection.CreateCommand();
command.CommandText = "insert into ProfitCategories(name, IdUser/*this is foreign key to Users table*/) values ( '" + name + "', '"+user+"' )";
command.ExecuteNonQuery();
connection.Close();