SQL Server插入错误 [英] Sql server insertion error

查看:80
本文介绍了SQL Server插入错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮帮我.我收到错误,但是没有代码.当我运行该页面时,它显示了这样的错误
对对象"employeeinfm",数据库"samp",模式"dbo"的插入权限被拒绝."
是什么原因导致此错误.
请为此提出建议..

Hi Please help me. I m getting the error but not in code. While i run that page it shows an error like this
"INSERT permission denied on object ''employeeinfm'', database ''samp'', schema ''dbo''."
What is the cause of this error.
Please suggest a solution for this..

try
{
    cmd = new SqlCommand("insert into employeeinfm values (@employeeid,@employeename,@designation,@password,@confirmpwd)", cn);

    cmd.Parameters.Add("@employeeid", SqlDbType.NVarChar, 50)
                   .Value = Txtempid.Text;
    cmd.Parameters.Add("@employeename", SqlDbType.NVarChar, 50)
                   .Value = Txtename.Text;
    cmd.Parameters.Add("@designation", SqlDbType.NVarChar, 50)
                   .Value = Txtdesig.Text;
    cmd.Parameters.Add("@password", SqlDbType.NVarChar, 50)
                   .Value = Txtpwd.Text;
    cmd.Parameters.Add("@confirmpwd", SqlDbType.NVarChar, 50)
                   .Value = Txtconfirmpwd.Text;

    cn.Open();
    cmd.ExecuteNonQuery();
    Label7.Text = "Saved successfully!";
    cn.Close();
}
catch (Exception ex)
{
    Response.Write(ex.Message);
}



在此先感谢
Ramya.P
email:ramyaponnuswami@gmail.com



Thanks in advance
Ramya.P
email:ramyaponnuswami@gmail.com

推荐答案

那是因为您与SQL Server连接的用户没有权限插入到employeeinfm中表.

要向用户授予权限,请参见 http://msdn.microsoft.com/en-us/library/ms186717 .aspx [^ ]
That''s because the user you''re connected with to the SQL Server does not have permission to insert into your employeeinfm table.

To grant permissions to a user see http://msdn.microsoft.com/en-us/library/ms186717.aspx[^]


用于连接数据库的user没有权限插入employeeinfm表中.

该用户的GRANT权限.
The user used to connect to the database does not have permissions to insert into the employeeinfm table.

GRANT permissions for that user.


您好,

请检查employeeinfm表的架构.当我们创建表时,默认模式将为dbo,但是在许多情况下,当我们将此类数据库上传到实时服务器时,默认模式将被更改,例如用户名将为默认模式
例如

Hi,

Please check the schema for employeeinfm table. When we create table the default schema will be dbo, but in many cases when we upload such database to live server at that time default schema will be changed like username will be default schema
E.g.

dbo.employeeinfm [before]
samp.employeeinfm [after]



所以,请检查一下.如果是dbo,则需要该用户的写权限.



so, please check that. If it is dbo then you need the write permission for that user.


这篇关于SQL Server插入错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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