对对象'employee_info',数据库'payroll'模式dbo的INSERT权限被拒绝

问题描述 投票:12回答:3
 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim myconnection As SqlConnection
        Dim mycommand As SqlCommand
        Dim ra As Integer


        myconnection = New SqlConnection("server=IAI-004;uid=;pwd=;database=payroll")
        myconnection.Open()
        mycommand = New SqlCommand("INSERT INTO employee_info([employee_id],[first_name],[last_name],[middle_name],[email],[telephone],[gender],[status],[date_birth],[hire_date]) values ('" & Employee_idTextBox.Text & "','" & First_nameTextBox.Text & "','" & Last_nameTextBox.Text & "','" & Middle_nameTextBox.Text & "','" & EmailTextBox.Text & "','" & TelephoneTextBox.Text & "','" & GenderTextBox.Text & "','" & StatusTextBox.Text & "','" & Date_birthDateTimePicker.Text & "','" & Hire_dateDateTimePicker.Text & "')", myconnection)
        mycommand.ExecuteNonQuery()
        MessageBox.Show("New Row Inserted" & ra)
        myconnection.Close()
    End Sub

对对象'employee_info',数据库'payroll'模式dbo的插入权限被拒绝

我该如何解决这个问题?

sql-server sql-server-2005 vb.net-2010
3个回答
14
投票

您大概需要在SQL Server(SSMS)中执行此操作。

右键单击SQL-Server中的表,然后向用户授予INSERT权限。

(...)

  • 右键单击表格
  • 属性
  • 权限
  • ((如有必要)添加用户或角色
  • 单击用户/角色
  • 权限插入,在'grant'框内打勾。

顺便说一句,您可以直接通过TSQL进行此操作,但是如果您现在遇到此问题(您提到自己是新手,那么也许可以从GUI着手,先按上面的内容进行。)>

也-假设您有权在SSMS中执行此操作。如果您不是DBA / DBO,则可能需要与某人联系...:-)


1
投票

右键单击相关的应用程序池。点击高级设置识别身份,选择LocalSystem


0
投票

以管理员身份运行python,然后执行代码。这为我解决了问题。

© www.soinside.com 2019 - 2024. All rights reserved.