尝试在asp.net c中检索用户名时出错 [英] Error when try to retrive username in asp.net c#

查看:83
本文介绍了尝试在asp.net c中检索用户名时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧我认为我已经得到了正确的代码,但是当我运行程序时出现此错误,数据类型在条件表达式中不匹配。



Ok i think ive got the code right but im getting this error when i run the program, Data type mismatch in criteria expression.

{
           da.InsertCommand = new OleDbCommand("INSERT INTO Rented (DVDID, UserName) VALUES (@rent, @username)", conn);
           var currentUser = System.Web.Security.Membership.GetUser(User.Identity.Name);
           string username = currentUser.UserName; //** get UserName
          // string userName = Environment.UserName;


           da.InsertCommand.Parameters.AddWithValue("@rent", DG_Latest.SelectedRow.Cells[1].Text);
           da.InsertCommand.Parameters.AddWithValue("@username", currentUser.UserName);

           conn.Open();

           da.InsertCommand.ExecuteNonQuery();

           conn.Close();
           conn.Dispose();
       }

推荐答案

数据类型不匹配意味着您为数据库提供的数据与数据库不匹配数据库列中的数据。
Data Type Mismatch means that the data you're giving the DB does not match the data in the column of the database.


这篇关于尝试在asp.net c中检索用户名时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆