.net 如何在WebMatrix中使用LAST_INSERT_ID()

.net 如何在WebMatrix中使用LAST_INSERT_ID(),.net,mysql,webmatrix,last-insert-id,.net,Mysql,Webmatrix,Last Insert Id,我在WebMatrix中搞不清楚如何为MySQL数据库使用LAST\u INSERT\u ID()。有人能告诉我如何将其应用于下面的代码段吗 var clothingsize=""; if(IsPost){ clothingsize =Request["clothingsize"]; var SQLINSERT = "INSERT INTO fit1 (clothingsize) VALUES (@0)"; } 我可以假设您正在使用MySQL.NET连接器吗 如

我在WebMatrix中搞不清楚如何为MySQL数据库使用
LAST\u INSERT\u ID()
。有人能告诉我如何将其应用于下面的代码段吗

var clothingsize="";
if(IsPost){     
clothingsize =Request["clothingsize"];         

var SQLINSERT = "INSERT INTO fit1 (clothingsize) VALUES (@0)"; }

我可以假设您正在使用MySQL.NET连接器吗

如果是这样的话,下面是一个非常简单的例子,说明你在寻找什么:

执行Insert命令(C#)后,连接存储在 条件连接):


快乐编码

以下是有效的解决方案:

就在注册页面上的此代码之后

db.Execute(SQLINSERT, fname, lname);
添加以下两行代码:

var customer_info_user_id = db.GetLastInsertId(); 
Response.Redirect("~/fit.cshtml?customer_info_user_id=" + customer_info_user_id);
然后在后续页面中插入以下内容:

在var之前打开数据库

var customer_info_user_id = Request["customer_info_user_id"];
添加已转入INSERT函数的id号。例如:

var SQLINSERT = "INSERT INTO fit (customer_info_user_id, clothingsize) VALUES (@0,@1)";                  
db.Execute(SQLINSERT, customer_info_user_id, clothingsize);
将id号转到下一页

Response.Redirect("~/flatter.cshtml?customer_info_user_id=" + customer_info_user_id);

感谢@Mike Brind和ASP.net论坛帮我解决了这个问题:-)

典型的,所以有些白痴投票否决了你的问题,因为他们不明白。请看这里:我没有使用连接器,但我想迈克刚刚回答了我的问题:-)
Response.Redirect("~/flatter.cshtml?customer_info_user_id=" + customer_info_user_id);