Solved

INSERT permission denied on object    ASP.net, SQL server

Posted on 2003-11-30
6
885 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

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 …
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.

777 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