小编Ant*_*ght的帖子

从“System.String”到“System.Guid”的转换无效

我的页面使用 GridView 在用户登录后向用户显示所有客户端。但是,我试图让 GridView 仅显示属于相应用户的那些客户端。

...背后的代码:

String strConnString = ConfigurationManager
    .ConnectionStrings["BA_2013ConnectionString"].ConnectionString;
SqlConnection con = new SqlConnection(strConnString);
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "getClients";
cmd.Parameters
    .Add("@UserId", SqlDbType.UniqueIdentifier)
    .Value = txtUserId.Text.ToString();
cmd.Connection = con;

con.Open();

gvClients.DataSource = cmd.ExecuteReader();
gvClients.DataBind();

con.Close();
con.Dispose(); 
Run Code Online (Sandbox Code Playgroud)

...存储过程:

ALTER PROCEDURE dbo.getClients
@UserId uniqueidentifier
AS
BEGIN
    SELECT ClientId, UserId, ClientName, EmailAddress, PhoneNumber, ServicesNum 
    FROM  Client_tb 
    WHERE UserId = @UserId  

END
Run Code Online (Sandbox Code Playgroud)

当我运行该页面时,出现错误:从“System.String”到“System.Guid”的转换无效...我可以获得一些帮助吗?

c# asp.net gridview

1
推荐指数
1
解决办法
2万
查看次数

标签 统计

asp.net ×1

c# ×1

gridview ×1