Solved

INSERT permission denied on object    ASP.net, SQL server

Posted on 2003-11-30
6
886 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
  • 2
  • 2
6 Comments
 
LVL 15

Expert Comment

by:Raisor
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:Raisor
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL SERVER - Index skipped a number 2 25
Database Integrity 1 48
changing page verifacation 1 25
Where is the Help Section? 8 24
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
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.

839 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