Click here to Skip to main content
15,896,063 members
Home / Discussions / C#
   

C#

 
AnswerRe: Help Regarding DATARELATIONSHIP Pin
Peace ON15-Jul-10 21:33
Peace ON15-Jul-10 21:33 
QuestionCircular dependency in dlls Pin
Blubbo15-Jul-10 7:53
Blubbo15-Jul-10 7:53 
AnswerRe: Circular dependency in dlls Pin
Richard MacCutchan15-Jul-10 9:00
mveRichard MacCutchan15-Jul-10 9:00 
GeneralRe: Circular dependency in dlls Pin
Blubbo15-Jul-10 9:02
Blubbo15-Jul-10 9:02 
GeneralRe: Circular dependency in dlls Pin
Richard MacCutchan15-Jul-10 9:37
mveRichard MacCutchan15-Jul-10 9:37 
AnswerRe: Circular dependency in dlls Pin
_Maxxx_15-Jul-10 18:05
professional_Maxxx_15-Jul-10 18:05 
GeneralRe: Circular dependency in dlls Pin
Blubbo19-Jul-10 2:26
Blubbo19-Jul-10 2:26 
QuestionError when using stored procedure in C#.net Pin
Dhyanga15-Jul-10 5:08
Dhyanga15-Jul-10 5:08 
Hi,

I have a problem when i try to use stored procedure in C#.net. Well when i run the stored procedure in sql server , it works fine and when the same query if i run in C#.net without using stored procedure, it works fine too. But when i try to use stored procedure in c#.net, it gave errors. The error is like this:



System.Data.SqlClient.SqlException: The EXECUTE permission was denied on the object 'SelectItem', database 'Student', schema 'dbo'. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlDataReader.ConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) at Default_View.DisplayItem() in C:\Documents and Settings\smanandhar\My Documents\Visual Studio 2008\Projects\StudentPortlet\Default_View.ascx.cs:line 285


the stored procedure is :
ALTER PROCEDURE [dbo].[SelectItem]
@UserID nvarchar (50)

AS
BEGIN TRANSACTION
select i.Item,i.ItemDescription,i.Category,i.Amount,i.SubmissionDate,i.ProposalID from ProposalItem i,Proposal j where
i.ProposalID = j.ID
and
j.UserID = @UserID
COMMIT TRANSACTION


and the code in C# is:
try
{
SqlConnection cnx = new SqlConnection(StudentPortlet.strCnx);
SqlCommand cmd = new SqlCommand();
cmd = new SqlCommand("SelectItem", cnx);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@UserID", SqlDbType.NVarChar).Value = "Unknown";
SqlDataAdapter adap = new SqlDataAdapter(cmd);
DataSet dtt = new DataSet("student senate budget testing");
adap.Fill(dtt);
System.Web.UI.WebControls.DataGrid grid = new System.Web.UI.WebControls.DataGrid();
grid.HeaderStyle.Font.Bold = true;
grid.DataSource = dtt;

grid.DataBind();
dgDisplayItem.DataSource = dtt;
dgDisplayItem.DataBind();
}
catch (Exception ex)
{
string s = ex.ToString();
}

sm
AnswerRe: Error when using stored procedure in C#.net Pin
T M Gray15-Jul-10 6:25
T M Gray15-Jul-10 6:25 
GeneralRe: Error when using stored procedure in C#.net Pin
Dhyanga15-Jul-10 6:30
Dhyanga15-Jul-10 6:30 
AnswerRe: Error when using stored procedure in C#.net Pin
GgAben21-Jul-10 2:06
GgAben21-Jul-10 2:06 
Questionhi can any one suggest me quickest(optimized) way to call an stored procedure from my c# code for every row of data table (rows can be for example 20000)? what is "optimized" ? Pin
sohailch4015-Jul-10 3:45
sohailch4015-Jul-10 3:45 
AnswerRe: hi can any one suggest me quickest(optimized) way to call an stored procedure from my c# code for every row of data table (rows can be for example 20000)? what is "optimized" ? Pin
Ennis Ray Lynch, Jr.15-Jul-10 3:55
Ennis Ray Lynch, Jr.15-Jul-10 3:55 
QuestionDictionary <-> JSON Pin
softwarejaeger15-Jul-10 1:57
softwarejaeger15-Jul-10 1:57 
AnswerRe: Dictionary JSON Pin
Peace ON15-Jul-10 2:12
Peace ON15-Jul-10 2:12 
Questionmove items up and down in listbox Pin
NarVish15-Jul-10 1:29
NarVish15-Jul-10 1:29 
AnswerRe: move items up and down in listbox Pin
Peace ON15-Jul-10 1:45
Peace ON15-Jul-10 1:45 
GeneralRe: move items up and down in listbox Pin
NarVish15-Jul-10 3:37
NarVish15-Jul-10 3:37 
QuestionQuestion on reflection Pin
Dewald14-Jul-10 23:30
Dewald14-Jul-10 23:30 
AnswerRe: Question on reflection Pin
Arun Jacob14-Jul-10 23:36
Arun Jacob14-Jul-10 23:36 
GeneralRe: Question on reflection Pin
Dewald15-Jul-10 0:57
Dewald15-Jul-10 0:57 
AnswerRe: Question on reflection [modified] Pin
PIEBALDconsult15-Jul-10 3:25
mvePIEBALDconsult15-Jul-10 3:25 
GeneralRe: Question on reflection Pin
Dewald15-Jul-10 4:19
Dewald15-Jul-10 4:19 
Questionproxy problem Pin
mstfync14-Jul-10 21:02
mstfync14-Jul-10 21:02 
AnswerRe: proxy problem Pin
Pete O'Hanlon14-Jul-10 21:49
mvePete O'Hanlon14-Jul-10 21:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.