Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

INSERT permission denied on object    ASP.net, SQL server

Posted on 2003-11-30
6
Medium Priority
?
892 Views
Last Modified: 2007-12-19
sorry for the double post.. but i have no idea who to talk to about moving a post..


This is an XML web service that I am testing from my computer Trying to update a table. SQL server permissions are set to give user 215, compleat control, I've selected that he can do absolutly everything I could click on.

I've also turned on "Cross database ownership chaining" even though it shouldn't need it I would think.

http://www.telusplanet.net/public/millsy/perm.png


<?xml version="1.0" encoding="utf-8" ?>
  <string xmlns="http://tempuri.org/gmills/Create_Forum">System.Data.SqlClient.SqlException: INSERT permission denied on object 'admin', database 'Forum', owner 'dbo'. at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at xxxx.Create_Forum.Create(String Name, Int32 Owner) in F:\Documents and Settings\Administrator\VSWebCache\xxxxs\WebServices\Create_Forum.asmx.vb:line 87</string>



=========code===========
<WebMethod()> _
    Public Function Create(ByVal Name As String, ByVal Owner As Integer) As String
        Dim myConnection As New SqlConnection
        Dim sqlstr As New SqlCommand


        myConnection.ConnectionString = "Data Source={SQL Server}; Server=MILLSY; Database=FORUM; Trusted_Connection=no; user id=215; password=XXXXXXX"
        Dim SQL As String = ("create table " & Name.ToString & " ( Thread_id INT,Thread_title varchar,post_count int IDENTITY(1,1)  NOT FOR REPLICATION CHECK NOT FOR REPLICATION (post_count <= 10000) NOT NULL,last_post datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, post_starter Int)")
       
        Dim sql2 As String = ("insert into admin (admin_id, ForumName) values (" + Owner.ToString + ", '" + Name.ToString + "')")

        sqlstr.CommandText = SQL
        sqlstr.Connection = myConnection
        Dim myTrans As SqlTransaction
        sqlstr.Connection.Open()
        myTrans = sqlstr.Connection.BeginTransaction()

        Try


            sqlstr.Transaction = myTrans

            sqlstr.ExecuteNonQuery()
            sqlstr.CommandText = sql2
            sqlstr.ExecuteNonQuery()

            myTrans.Commit()

        Catch ex As SqlException
            myTrans.Rollback()
            Return ex.ToString
        End Try
        sqlstr.Connection.Close()

        Return "Worked"


    End Function
==================================
0
Comment
Question by:_Millsy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
6 Comments
 
LVL 15

Expert Comment

by:Ralf Klatt
ID: 9846455
Hi,

Try to make your user 215 a DB owner too ... if not yet done!

Best regards, Raisor
0
 

Author Comment

by:_Millsy
ID: 9847726
already done.

in fact, for a while I even had public as DBO owner... I just don't know what the problem is.
0
 

Author Comment

by:_Millsy
ID: 9848465
Well guess what.. i fixed it... and it's one of those ARG WHAT IN THE SAM HELL kind of moments...


Catch ex As SqlException


changed to


Catch ex As Exception

no errors, everything added to the database correctly...


all i have to say is.. HUH!?!
0
 
LVL 15

Expert Comment

by:Ralf Klatt
ID: 9848496
Hi,

Good to know ... thanks for publishing the solution!

Best regards, Raisor
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 11533615
PAQed, with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question