Solved

INSERT permission denied on object    ASP.net, SQL server

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

729 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