INSERT permission was denied on the object 'employee_info', database 'payroll' schema dbo
Asked Answered
R

4

17
 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

INSERT permission was denied on the object 'employee_info', database 'payroll' schema dbo

how can i resolve this problem?

Relativistic answered 16/1, 2014 at 23:21 Comment(0)
R
22

You'll need to do this (presumably) in SQL-Server (SSMS).

Right-click the table in SQL-Server and give INSERT permissions to the user.

(...)

  • Right Click the table
  • Properties
  • Permissions
  • (if necessary) add the user or role
  • click on the user/role
  • permission insert, put a check-mark in the 'grant' box.

BTW -- you can do this via TSQL directly, but if you're having this problem now (you mention that you're new), then maybe start with the GUI, per above first.

Also -- this assumes you have access to do this in SSMS. If you're not the DBA / DBO, then you might need to contact somebody... :-)

Rebutter answered 16/1, 2014 at 23:23 Comment(3)
i already gave a permission not only insert also update, delete and select. but it does`NT work. :(Relativistic
This didn't resolve the error message for me. Anyone else who faces this issue?Tonl
I had the same problem. For me the problem was that I had given the User membership of all roles including "db_denydatawriter". This of course caused prevented him from writing.Brutalize
T
2

Right Click on the Application Pool concerned. Click Advanced Settings Indentify Identity, Select LocalSystem

That should do the job.

If Answer provided previously works, then it means everytime the password changes, which must change in a normal Enterprise, you will need to update these connection strings as well, and you dont want to do that.

Trisect answered 4/11, 2014 at 13:23 Comment(0)
D
2

you can resolve this problem with re-run your last add-migration :

for example my last migration name is : initial

1: Add-Migration "initial" -force

2: Update-Database

Dissymmetry answered 6/1, 2021 at 9:2 Comment(0)
O
-2

Run python as an admin then execute the code. That solved the problem for me.

Orlon answered 31/12, 2019 at 17:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.