Solved

INSERT permission denied on object    ASP.net, SQL server

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
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 …
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…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now