Showing posts with label below. Show all posts
Showing posts with label below. Show all posts

Tuesday, March 27, 2012

Executing more than one query

Hi,

How to execute more than one query consecutively in SqlDataSource like the picture shown below.

you could put multiple statements together by seperating them with a semicolon:

insert blah into blah; insert blah2 into blah2; insert somethingelse into somewhereelse;

|||

Hello my friend,

You should be able to put 1 INSERT/UPDATE/DELETE statement one after the other. Another approach would be to specify a stored procedure to do the INSERT/UPDATE/DELETE and then within the stored procedure have multiple INSERT/UPDATE/DELETE commands. Below is an example SQL script that will create a stored procedure: -

CREATE PROCEDURE usp_InsertClientWithPreference
(
@.ClientName AS VARCHAR(250),
@.ContactNumber AS VARCHAR(20),
@.VacationCountry AS VARCHAR(250)
)

AS

INSERT INTO tblClient (ClientName, ContactNumber)
VALUES (@.ClientName, @.ContactNumber)

UPDATE tblFavourites SET Total = (Total + 1)
WHERE Country = @.VacationCountry


RETURN

Kind regards

Scotty

|||

Thanks sirs..You showed your best quality as always you showSmile

Regards..

Monday, March 26, 2012

Executing BCP statement throws out the error

Hi

When I execute a simple BCP statement as shown below. It throws out an error message as pasted below. Any help on this is highly appreciated.

Use master
Exec xp_cmdshell 'bcp "select * from Mydb..Records" queryout "D:\Book1.xls" -U [sa] -P [pwd] -c'

SQLState = S1010, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver]Function sequence error
NULL

Thanks!

No replies to this question? We are using sp_oamethod and when calling the bcp.exe, getting the same error message.|||

can you provide some sample data and DDL?

|||There seemed to be a limit in the temp table for the bcp into a file. If the table contained 20 or less rows, it worked correctly. If the table had 21 + rows, then the bcp failed (the temp table was created and populated during the execution of a proc that then would bcp the data to a file). We ended up replacing the select statement with the temp table name and using "out" instead of "queryout". That fixed the problem. We can not explain what the reason was though.|||

I had the same problem, only instead of Excel files I was using XML files.

Anyway, it looks like it is an internal SQL Server error, and after restarting SQL Server, everything was back to normal.

Executing BCP statement throws out the error

Hi

When I execute a simple BCP statement as shown below. It throws out an error message as pasted below. Any help on this is highly appreciated.

Use master
Exec xp_cmdshell 'bcp "select * from Mydb..Records" queryout "D:\Book1.xls" -U [sa] -P [pwd] -c'

SQLState = S1010, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver]Function sequence error
NULL

Thanks!

No replies to this question? We are using sp_oamethod and when calling the bcp.exe, getting the same error message.|||

can you provide some sample data and DDL?

|||There seemed to be a limit in the temp table for the bcp into a file. If the table contained 20 or less rows, it worked correctly. If the table had 21 + rows, then the bcp failed (the temp table was created and populated during the execution of a proc that then would bcp the data to a file). We ended up replacing the select statement with the temp table name and using "out" instead of "queryout". That fixed the problem. We can not explain what the reason was though.|||

I had the same problem, only instead of Excel files I was using XML files.

Anyway, it looks like it is an internal SQL Server error, and after restarting SQL Server, everything was back to normal.

Executing BCP statement throws out the error

Hi

When I execute a simple BCP statement as shown below. It throws out an error message as pasted below. Any help on this is highly appreciated.

Use master
Exec xp_cmdshell 'bcp "select * from Mydb..Records" queryout "D:\Book1.xls" -U [sa] -P [pwd] -c'

SQLState = S1010, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver]Function sequence error
NULL

Thanks!

No replies to this question? We are using sp_oamethod and when calling the bcp.exe, getting the same error message.|||

can you provide some sample data and DDL?

|||There seemed to be a limit in the temp table for the bcp into a file. If the table contained 20 or less rows, it worked correctly. If the table had 21 + rows, then the bcp failed (the temp table was created and populated during the execution of a proc that then would bcp the data to a file). We ended up replacing the select statement with the temp table name and using "out" instead of "queryout". That fixed the problem. We can not explain what the reason was though.|||

I had the same problem, only instead of Excel files I was using XML files.

Anyway, it looks like it is an internal SQL Server error, and after restarting SQL Server, everything was back to normal.

sql

Wednesday, March 21, 2012

ExecuteReader: Connection property has not been initialized.

I have a web form that is generating an error and I can't seem to figure out why for the life of me. Below is the code:


Private Sub VerifyNoDuplicateEmail()
Dim conn As SqlConnection
Dim sql As String
Dim cmd As SqlCommand
Dim id As Guid
sql = "Select UserID from SDCUsers where email='{0}'"
sql = String.Format(sql, txtEmail.Text)
cmd = New SqlCommand(sql, conn)
conn = New SqlConnection(ConfigurationSettings.AppSettings("cnSDCADC.ConnectionString"))
conn.Open()
Try
'The first this we need to do here is query the database and verify
'that no one has registed with this particular e-mail address
id = cmd.ExecuteScalar()
Response.Write(id.ToString & "<BR>")
Catch
Response.Write(sql & "<BR>")
Response.Write("An error has occurred: " & Err.Description)
Finally
If Not id.ToString Is Nothing Then
'The e-mail address is already registered.
Response.Write("Your e-mail address has already been registered with this site.<BR>")
conn.Close()
_NoDuplicates = False
Else
'It's safe to add the user to the database
conn.Close()
_NoDuplicates = True
End If
End Try
End Sub

Web.Config
<appSettings>
<!-- User application and configured property settings go here.-->
<!-- Example: <add key="settingName" value="settingValue"/> -->
<add key="cnSDCADC.ConnectionString" value="workstation id=STEPHEN;packet size=4096;integrated security=SSPI;data source=SDCADC;persist security info=False;initial catalog=sdc" />
</appSettings>

Can anyone show me the error of my ways?

Thanks,
StephenPlease elaborate on "generating an error". An exact error mesage will probably go a long way in helping you correct your problem.

Also, please use parameters and not string concetenation to build your SQL commands!!

Instead of this:


sql = "Select UserID from SDCUsers where email='{0}'"
sql = String.Format(sql, txtEmail.Text)
cmd = New SqlCommand(sql, conn)

do something like this:

sql = "Select UserID from SDCUsers where email=@.email"
cmd = New SqlCommand(sql, conn)
cmd.Parameters.Add(New SqlParameter("@.email", SqlDbType.VarChar, 99)).Value = txtEmail.Text

Terri|||Terri,

The exact error is the title of the thread "ExecuteReader: Connection property has not been initialized."

Thanks,

Stephen|||Terri,

I tried the changes you suggested and still recieved the same error. After taking a little time off and coming back the to the problem I finally found the error of my ways. I was initializing the CMD object before the CONN object. Thanks for you help.

Stephen|||Oh yes, so you were. :-)

Please use parameters anyway -- that suggestion was something of an aside. And next time you post please include the error message. We could have helped you a lot quicker with that information!

Terri

Monday, March 19, 2012

ExecuteNonQuery() not giving correct affected rows

When I use ExecuteNonQuery() with the stored procedure below it returns -1. However, when i tried to get rid of the if/else statements and just leave one insert statement for testing purposes, ExecuteNonQuery() returns the correct affected rows which is 1. So it seems like ExecuteNonQuery() doesn't work when the INSERT statement is inside the IF..ELSE. Can anybody help me with this problem? I haven't tried using @.@.RowCount because I really want to use ExecuteNonQuery() to do this because I don't want to rewrite my DAL. Thanks in advance

-- With if/else ExecuteNonQuery returns -1

ALTER PROCEDURE [dbo].[SP_AddObjectContribution]
@.ObjectId int,
@.FanId int,
@.DateContributed DateTime,
@.Notes nvarchar(512),
@.ObjectType int
AS

BEGIN

BEGIN TRAN
IF @.ObjectType = 2
BEGIN
INSERT INTO FighterContributions
(FighterId, FanId, DateContributed, Notes) VALUES
(@.ObjectId, @.FanId, @.DateContributed, @.Notes)
END
ELSE IF @.ObjectType = 3
BEGIN
INSERT INTO FighterPhotoContributions
(FighterPhotoId, FanId, DateContributed, Notes) VALUES
(@.ObjectId, @.FanId, @.DateContributed, @.Notes)
END
ELSE IF @.ObjectType = 4
BEGIN
INSERT INTO OrganizationContributions
(OrganizationId, FanId, DateContributed, Notes) VALUES
(@.ObjectId, @.FanId, @.DateContributed, @.Notes)
END
ELSE IF @.ObjectType = 5
BEGIN
INSERT INTO EventContributions
(EventId, FanId, DateContributed, Notes) VALUES
(@.ObjectId, @.FanId, @.DateContributed, @.Notes)
END
ELSE IF @.ObjectType = 6
BEGIN
INSERT INTO FightContributions
(FightId, FanId, DateContributed, Notes) VALUES
(@.ObjectId, @.FanId, @.DateContributed, @.Notes)
END
ELSE IF @.ObjectType = 7
BEGIN
INSERT INTO FightPhotoContributions
(FightPhotoId, FanId, DateContributed, Notes) VALUES
(@.ObjectId, @.FanId, @.DateContributed, @.Notes)
END

IF @.@.ERROR <> 0
BEGIN
ROLLBACK RETURN
END

COMMIT TRAN

END

-- Without if/else ExecuteNonQuery returns 1

ALTER PROCEDURE [dbo].[SP_AddObjectContribution]
@.ObjectId int,
@.FanId int,
@.DateContributed DateTime,
@.Notes nvarchar(512),
@.ObjectType int
AS

BEGIN

BEGIN TRAN

INSERT INTO FighterContributions
(FighterId, FanId, DateContributed, Notes) VALUES
(@.ObjectId, @.FanId, @.DateContributed, @.Notes)

IF @.@.ERROR <> 0
BEGIN
ROLLBACK RETURN
END

COMMIT TRAN

END

1ALTER PROCEDURE [dbo].[SP_AddObjectContribution]2 @.ObjectIdint,3 @.FanIdint,4 @.DateContributedDateTime,5 @.Notesnvarchar(512),6 @.ObjectTypeint7AS89BEGIN1011 BEGIN TRAN12 IF @.ObjectType = 213BEGIN14 INSERT INTO FighterContributions15 (FighterId, FanId, DateContributed, Notes)VALUES16 (@.ObjectId, @.FanId, @.DateContributed, @.Notes)17RETURN@.@.ROWCOUNT18END1920END212223
Try each statement like this
|||

RETURN @.@. ROWCOUNT on each statement won't work because it won't commit the transaction (it won't hit COMMIT TRAN).

|||

Perhaps you can add an OUTPUT Parameter to get the rows affected. Instead of this statement: IF @.@.ERROR <> 0, try:

SELECT @.rows = @.@.ROWCOUNT, @.Error = @.@.ERROr

IF @.ERROR <> 0

You will have to declare the @.Rows and @.Error variables. Add @.Rows to the parameters list as OUTPUT param. Check the value in @.rows from your front end.

|||

I think only one insert statment will execute at one time based on parameter.. don;t kwno why u are using transaction for single insert. ? Is this correctSurprise

|||

I'm sorry guys. I think I messed up while testing the method because right now the stored procedure in question is now working. I also added RETURN SCOPE_IDENTITY() to get the ID of the new inserted record and it works. So having INSERT statements inside IF ELSE is not a problem for executenonquery.

So this is the final procedure

ALTER PROCEDURE [dbo].[SP_AddObjectContribution]
@.ObjectId int,
@.FanId int,
@.DateContributed DateTime,
@.Notes nvarchar(512),
@.ObjectType int
AS
BEGIN
BEGIN TRAN
IF @.ObjectType = 2
BEGIN
INSERT INTO FighterContributions
(FighterId, FanId, DateContributed, Notes) VALUES
(@.ObjectId, @.FanId, @.DateContributed, @.Notes)
END
ELSE IF @.ObjectType = 3
BEGIN
INSERT INTO FighterPhotoContributions
(FighterPhotoId, FanId, DateContributed, Notes) VALUES
(@.ObjectId, @.FanId, @.DateContributed, @.Notes)
END
ELSE IF @.ObjectType = 4
BEGIN
INSERT INTO OrganizationContributions
(OrganizationId, FanId, DateContributed, Notes) VALUES
(@.ObjectId, @.FanId, @.DateContributed, @.Notes)
END
ELSE IF @.ObjectType = 5
BEGIN
INSERT INTO EventContributions
(EventId, FanId, DateContributed, Notes) VALUES
(@.ObjectId, @.FanId, @.DateContributed, @.Notes)
END
ELSE IF @.ObjectType = 6
BEGIN
INSERT INTO FightContributions
(FightId, FanId, DateContributed, Notes) VALUES
(@.ObjectId, @.FanId, @.DateContributed, @.Notes)
END
ELSE IF @.ObjectType = 7
BEGIN
INSERT INTO FightPhotoContributions
(FightPhotoId, FanId, DateContributed, Notes) VALUES
(@.ObjectId, @.FanId, @.DateContributed, @.Notes)
END

IF @.@.ERROR <> 0
BEGIN
ROLLBACK RETURN
END

COMMIT TRAN

RETURN SCOPE_IDENTITY()

END

For those who are interested, here is how to get the value of the new id. Ignore CreateParameter() method. It is just an abstraction.

IDataParameter param = CreateParameter("ReturnValue", DbType.Int32);
param.Direction = ParameterDirection.ReturnValue;
command.Parameters.Add(param);
connection.Open();
if (command.ExecuteNonQuery() > 0)
{
newObjectId = (int)((IDataParameter)command.Parameters["ReturnValue"]).Value;
}

|||

satya_tanwar:

I think only one insert statment will execute at one time based on parameter.. don;t kwno why u are using transaction for single insert. ? Is this correctSurprise

Actually, I am going to add delete statements before the insert statements later. Anyways, thanks for helping out.

|||

thats good mark the post as answered and close the post

ExecuteNonQuery for sql2005

I hope you would help me in this problem. I use the code below for executenonquery command for mdb DB.But I do not know the changes I should made when Using SQL2005.

----
Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=C:\ASPNET20\data\Northwind.mdb"
Dim dbConnection As New OleDbConnection(connectionString)
dbConnection.Open()

Dim commandString As String = "INSERT INTO Employees(FirstName, LastName) " & _
"Values(@.FirstName, @.LastName)"

Dim dbCommand As New OleDbCommand(commandString, dbConnection)

Dim firstNameParam As New OleDbParameter("@.FirstName", OleDbType.VarChar, 10)
firstNameParam.Value = txtFirstName.Text
dbCommand.Parameters.Add(firstNameParam)

Dim lastNameParam As New OleDbParameter("@.LastName", OleDbType.VarChar, 20)
LastNameParam.Value = txtLastName.Text
dbCommand.Parameters.Add(LastNameParam)

dbCommand.ExecuteNonQuery()

dbConnection.Close()
---

You can check SqlCommand class. You can take a look at this link:

http://msdn2.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.parameters.aspx

|||Search "Ole" and replace with "Sql"

Monday, March 12, 2012

Execute SSIS Package using SQl Server Agent

Hi

I hv created a new Job for my SSIS Package... but when i start the job manually it gives me this error below:

"Executed as User:localhost/SYSTEM. THe package could not be loaded.the Step Failed".

i have my package deployed in Storage Packages[MSDB]...

Could you help me on this....

THanks!

Karthik

it's all to do with security:

Your localhost/SYSTEM account probably has no access to the SISS storage [MSDB].

Either you have modify the sql agent job to run as a user with sufficient rights on the SISS store or you grant this account access.

Then there is also the possibility that this user account has not access to the databases that are opened by the package.

Friday, March 9, 2012

EXECUTE SQL TASK --> Object Reference Not Set to An Instance of an Object

Hi all,

Does anyone see the error below before?

I am using SSIS Execute SQL Task (ADO.NET) to update a table using a stored procedure.

It works like this many times for me and all of a sudden, not sure what is changing in the environment, I kept getting this WARNING when I click on PARSE QUERY

“Object Reference Not Set to An Instance of an Object” when I click on PARSE QUERY.

This is going against SQL SERVER 2005 SP2 x64 Enterprise.

Note that this task executes fine and the stored procedure updates data.

The stored procedure does the following.

There are other stored procedures of different kinds and they all worked.

But all of them give this error when I click on PARSE QUERY.

Code Snippet

DECLARE @.TodayDate datetime

SET @.TodayDate = GETDATE()

Exec dbo.updDimBatch

@.BatchKey = @.BatchKey,

@.ParentBatchKey = @.ParentBatchKey,

@.BatchName = 'Load Customer Increment',

@.BatchStartDate = NULL,

@.BatchEndDate = @.TodayDate,

@.StatusKey = NULL,

@.RowsInserted = @.Count_Insert,

@.RowsUpdated = @.Count_Update,

@.RowsException = NULL,

@.RowsError = NULL,

@.UpdatedDate = @.TodayDate,

@.BatchDescription = NULL

OLEDB Sample also give me syntax error

exec dbo.updDimBatch ?,?,'Load Activity Increment','6/27/2007','6/27/2007',1,?,?,0,0,'6/27/2007',''

I tried to change to OLEDB and call the stored procedure like this but got syntax error?

Not sure what is the error here.

I believe there is a known issue when trying to do a Parse Query with ADO.NET, when variables or parameters are being used. Does the task succeed if you execute it?|||

yes, it executes fine.

This is going against SQL SERVER 2005 SP2 x64 Enterprise.

Note that this task executes fine and the stored procedure updates data.

The stored procedure does the following.

This is just an example. But to call ANY STORED PROCEDURE will give the same problem.

I think it is a bug with the ADO.NET query parser.

Note that I saw this exact same error LAST YEAR with SP1. I think it never get fixed.

work around? customers don't want to use OLEDB because the syntax ?,? etc is not straightforward and easy to maintain.

They elect to just ignore it.

There are other stored procedures of different kinds and they all worked.

But all of them give this error when I click on PARSE QUERY.

Code Snippet

DECLARE @.TodayDate datetime

SET @.TodayDate = GETDATE()

Exec dbo.updDimBatch

@.BatchKey = @.BatchKey,

@.ParentBatchKey = @.ParentBatchKey,

@.BatchName = 'Load Customer Increment',

@.BatchStartDate = NULL,

@.BatchEndDate = @.TodayDate,

@.StatusKey = NULL,

@.RowsInserted = @.Count_Insert,

@.RowsUpdated = @.Count_Update,

@.RowsException = NULL,

@.RowsError = NULL,

@.UpdatedDate = @.TodayDate,

@.BatchDescription = NULL

EXECUTE SQL TASK --> Object Reference Not Set to An Instance of an Object

Hi all,

Does anyone see the error below before?

I am using SSIS Execute SQL Task (ADO.NET) to update a table using a stored procedure.

It works like this many times for me and all of a sudden, not sure what is changing in the environment, I kept getting this WARNING when I click on PARSE QUERY

“Object Reference Not Set to An Instance of an Object” when I click on PARSE QUERY.

This is going against SQL SERVER 2005 SP2 x64 Enterprise.

Note that this task executes fine and the stored procedure updates data.

The stored procedure does the following.

There are other stored procedures of different kinds and they all worked.

But all of them give this error when I click on PARSE QUERY.

Code Snippet

DECLARE @.TodayDate datetime

SET @.TodayDate = GETDATE()

Exec dbo.updDimBatch

@.BatchKey = @.BatchKey,

@.ParentBatchKey = @.ParentBatchKey,

@.BatchName = 'Load Customer Increment',

@.BatchStartDate = NULL,

@.BatchEndDate = @.TodayDate,

@.StatusKey = NULL,

@.RowsInserted = @.Count_Insert,

@.RowsUpdated = @.Count_Update,

@.RowsException = NULL,

@.RowsError = NULL,

@.UpdatedDate = @.TodayDate,

@.BatchDescription = NULL

OLEDB Sample also give me syntax error

exec dbo.updDimBatch ?,?,'Load Activity Increment','6/27/2007','6/27/2007',1,?,?,0,0,'6/27/2007',''

I tried to change to OLEDB and call the stored procedure like this but got syntax error?

Not sure what is the error here.

I believe there is a known issue when trying to do a Parse Query with ADO.NET, when variables or parameters are being used. Does the task succeed if you execute it?|||

yes, it executes fine.

This is going against SQL SERVER 2005 SP2 x64 Enterprise.

Note that this task executes fine and the stored procedure updates data.

The stored procedure does the following.

This is just an example. But to call ANY STORED PROCEDURE will give the same problem.

I think it is a bug with the ADO.NET query parser.

Note that I saw this exact same error LAST YEAR with SP1. I think it never get fixed.

work around? customers don't want to use OLEDB because the syntax ?,? etc is not straightforward and easy to maintain.

They elect to just ignore it.

There are other stored procedures of different kinds and they all worked.

But all of them give this error when I click on PARSE QUERY.

Code Snippet

DECLARE @.TodayDate datetime

SET @.TodayDate = GETDATE()

Exec dbo.updDimBatch

@.BatchKey = @.BatchKey,

@.ParentBatchKey = @.ParentBatchKey,

@.BatchName = 'Load Customer Increment',

@.BatchStartDate = NULL,

@.BatchEndDate = @.TodayDate,

@.StatusKey = NULL,

@.RowsInserted = @.Count_Insert,

@.RowsUpdated = @.Count_Update,

@.RowsException = NULL,

@.RowsError = NULL,

@.UpdatedDate = @.TodayDate,

@.BatchDescription = NULL

Wednesday, March 7, 2012

Execute Scalar ?

I'm trying to do something like the code below, but it's saying "specified cast is not valid"

If i change the value returned to an "int", it works fine. My issue is, i'd like to get the value returned with more accuracy than an int as there will be 2 decimal places.

protectedfloat getProjectHours(string project)

{

string selectCmd ="SELECT SUM(hours) FROM tasks WHERE project=@.project";

string strConnection =ConfigurationManager.ConnectionStrings["TimeAccountingConnectionString"].ConnectionString;

SqlConnection myConnection =newSqlConnection(strConnection);

SqlCommand myCommand =newSqlCommand(selectCmd, myConnection);

myCommand.Parameters.Add(newSqlParameter("@.project",SqlDbType.VarChar));myCommand.Parameters["@.project"].Value = project;

myConnection.Open();

float total = (float)myCommand.ExecuteScalar();

myConnection.Close();

return total;

}

Could you post the sql function please?

|||

what do mean? it's all up there

|||

If this is the line you are getting an error on, then try this:

double total = Convert.ToDouble(myCommand.ExecuteScalar());

|||

worked perfect! Thanks!

|||

you are welcome...

|||

Oh, sorry. Need more coffee...

Sunday, February 26, 2012

EXECUTE permission deny

Any one can help me, below error messages for reference, thanks!

Exception Details:System.Data.SqlClient.SqlException: EXECUTE permission denied on object 'sp_insertspend', database 'master', owner 'dbo'.

Source Error:

Line 96: cmdMid.Connection = conMid;Line 97: cmdMid.CommandText = "exec sp_insertspend '" + uid + "','" + Mid + "','" + status + "','" + spend + "'";Line 98: cmdMid.ExecuteNonQuery();Line 99: conMid.Close();Line 100:


Source File:f:\Microsoft Visual Studio 8\Web\Soccer\main.aspx.cs Line:98

Stack Trace:

[SqlException (0x80131904): EXECUTE permission denied on object 'sp_insertspend', database 'master', owner 'dbo'.] System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +857322 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +734934 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1838 System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) +192 System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +380 System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +135 _Default.btnbet_Click(Object sender, EventArgs e) in f:\Microsoft Visual Studio 8\Web\Soccer\main.aspx.cs:98 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102

Hi there,

In SQL Server Managment Studio under Database Properties / Permissions you have to tickgrant execute permissionthe user or role you are using to connect to the database.