15,902,937 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by ganesh.dks (Top 12 by date)
ganesh.dks
13-Aug-15 4:50am
View
Considering these lines:-
Employee employee1 = new Employee();
Person person1 = employee1;
Console.WriteLine("person1 name:{0}",person1.name);
Person person2 = new Employee();
// Allowed because person1 is actually an Employee.
Employee employee2 = (Employee)person1;
If I write person.Designation in the WriteLine statement it throws a compile time error. But again when I reassign the person1 to Employee object (employee2) the employee2 can be used to access Designation. Now when I assigned the employee1 to person1 what happens to the Designation field. Because in the first WriteLine I could never access Designation using person1(naturally) because it is person. But then what happens to the Designation field which appears back when I assign employee2 with person1(casted). Hope you understand what I intend to say.
Say I had Data in the employee object which I assigned to person1, will that be persistent when I use person1 in the 5th statement. Will this be a good technique in any manner in software development practice?
ganesh.dks
1-Dec-14 3:47am
View
The final section is creating problems.
///////////////////////////////
FileInfo file = new FileInfo(oXL.ActiveWorkbook.FullName);
oWB.SaveAs(oSheet.Name + ".xls", Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookDefault,
Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive,
Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value);
HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=" + oSheet.Name + ".xls");
HttpContext.Current.Response.AddHeader("Content-Type", "application/Excel");
HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
HttpContext.Current.Response.AddHeader("Content-Length", file.Length.ToString());
HttpContext.Current.Response.WriteFile(file.FullName);
oWBs.Close();
oXL.Quit();
GC.Collect();
HttpContext.Current.Response.End();
////////////////////////////////////
ganesh.dks
30-Jun-14 23:27pm
View
I am using a server control to fetch and show data from db, so the Relevant Html contains
:-
<html>
<body>
<div id="CopyMyGrid">
</div>
<asp:updatePanel>
<div id="PivotGridDiv">
<PivotGrid id="pv" ........ atributes>
<elements>
Rendered as HTML Table (ctl00_ContentPlaceHolder1_ASPxPivotGrid1_HZST)
</PivotGrid>
</div>
</body>
</html>
Please don't get annoyed as I have not given the complete code but it contains a lot of elements which are rendered as the given HTML table. The only element I cannot show in the html is the "pivotGrid_PagerClick('ctl00_ContentPlaceHolder1_ASPxPivotGrid1', this, 'PBN');" because it is generated dynamically. Its a next button which fetches the next set of records.
So what I am trying to do is click the next button programmatically and then load those records into the new COpMyGrid div on scroll. This is inevitable because the control does some inherent data manipulation and the desired output is only obtained from it.
I need to bind the JQuery events on callbacks or partial postbacks but to the div again. It is not showing any error but nothing happens even when I scroll. One more issue is to know whether I can bind the scroll to a div which has the control behind my current div and get the data from it and load it to the div in front.
ganesh.dks
8-Jun-14 12:56pm
View
I Tried using this,
delete from UserRole where RoleID = @RoleID AND UserID IN (Select UserID from UserRole)
INSERT INTO UserRole(UserID, RoleId) SELECT id, @RoleID FROM dbo.CSVToTable(@UserID)
This once did what I wanted but also threw this error later.
Msg 217, Level 16, State 1, Procedure AssignRoleToUser, Line 7
Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32).
Its a simple procedure and I am unable to get right. I don't know perhaps I have forgotten everything.
ganesh.dks
8-Jun-14 12:47pm
View
Sorry but I am unable to comprehend.
According to the code you gave me it will delete all the users(specified in the list) with the given role. But if we are assigning a new role there isn't any need to delete because there are no such users assigned to the role.
And again if a user has a role already, and I intend to change his role , I am not fetching such an ID from the frontend because there is no support for unchecked event in the treeview I am using. The page would simple iterate and get the selected list only.
With these selected list I generate the ID list from the underlying DataSet. Now in your query the old role will still be there for a user even though the user intends to revoke his role by unchecking the user checkbox. Where as what I want is to delete all users with the given role everytime and insert or assign the role to the specified users list. Which is why I wanted to delete the whole set of users who had this role already. Kindly help me do this. And a lot many thanks for patiently answering my queries.
ganesh.dks
7-Jun-14 16:28pm
View
And swiggly line isn't just showing, there is indeed something wrong, Since I am not good at sql I am unable to figure out.
ganesh.dks
7-Jun-14 16:25pm
View
Nope that didn't solve the issue,
DECLARE @User VARCHAR(200)
SET @User = '1,3'
declare @ROLEID int
declare @USERID int
set @ROLEID=2
insert into userrole values(@UserID in (Select * from dbo.CSVToTable(@User) ,@ROLEID)
The issue arises when I put that @UserID in (Select * from dbo.CSVToTable(@User) in the insert statement, I am not that good at sql. Shouldn't I use it that way.
ganesh.dks
7-Jun-14 15:28pm
View
I tried doing this but still didn't get it to work:-
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
alter procedure [dbo].[UserAdmin_UserRoles_IU]
@RoleID int,
@UserIDs varchar(max)
As
BEGIN
Begin transaction
--declare @Instr varchar(max)
declare @TempTab table (id int)
delete from UserRole where RoleID = @RoleID
--and UserID=(Select tbl.id from dbo.CSVToTable(@UserIDs) tbl)
IF (@@ERROR <> 1)
BEGIN
SET @UserIDs = REPLACE(@UserIDs + ',', ',,', ',')
DECLARE @SP INT
DECLARE @VALUE VARCHAR(1000)
WHILE PATINDEX('%,%', @UserIDs ) <> 0
BEGIN
SELECT @SP = PATINDEX('%,%',@UserIDs)
SELECT @VALUE = LEFT(@UserIDs , @SP - 1)
SELECT @UserIDs = STUFF(@UserIDs, 1, @SP, '')
INSERT INTO @TempTab(id) VALUES (@VALUE)
Insert into UserRole (UserID,RoleID )
Select tbl.id ,@RoleID RoleID
from
@TempTab tbl
END
IF (@@ERROR <> 1)
BEGIN
commit transaction
END
ELSE
BEGIN
ROLLBACK TRAN
END
END
END
ganesh.dks
7-Jun-14 15:04pm
View
OK Thanks a lot I got it, It was long back in 2009 I used to teach sql server and c#.net to graduates. But it took years for me to get into the software industry when I forgot almost many important things.
I have got one problem though, when I use your function in my stored procedure it still throws the same problem u mentioned. I am having to manually pass the ID string. I am not able to pass the variable.
Here is my proc:-
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
alter procedure [dbo].[UserAdmin_UserRoles_IU]
@RoleID int,
@UserIDs varchar(max)
As
Begin
Begin transaction
delete from UserRole where RoleID = @RoleID
--and UserID=(Select tbl.id from dbo.CSVToTable(@UserIDs) tbl)
IF (@@ERROR <> 1)
begin
Insert into UserRole (UserID,RoleID )
Select tbl.id ,@RoleID RoleID
from
dbo.CSVTOTable(@UserIDs) tbl
end
IF (@@ERROR <> 1)
begin
commit transaction
end
else
begin
ROLLBACK TRAN
End
End
However This doesn't work
DECLARE @LIST VARCHAR(200)
SET @LIST = '11,12,13,14,15,16';
[UserAdmin_UserRoles_IU] 2 , @List
The same problem you told earlier (conversion error).
Does that mean that I will have to go and write the same code again. Pardon if I am foolish. I need to learn a lot from experts like you.
ganesh.dks
7-Jun-14 14:25pm
View
Also this is to delete and insert not to update so I would Like to know how to insert values with a scalar parameter and a list parameter.
ganesh.dks
7-Jun-14 13:34pm
View
I know I made a mistake using Tran twice , but code doesn't throw any error, but instead shows the number of affected rows. And when I check the table nothing seems to have happened , no update at all.
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[UserAdmin_UserRoles_IU]
@RoleID int,
@UserIDs varchar(max)
As
Begin
BEGIN TRAN
Begin transaction
delete from UserRoles where RoleID = @RoleID
IF (@@ERROR <> 0) GOTO ERR_HANDLER
Insert into UserRoles (UserID,RoleID )
Select
tbl.Item ,@RoleID RoleID
--Also tried this -- tbl.Item UserID, @RoleID RoleID
from
dbo.fnSplit(@UserIDs,',') tbl
IF (@@ERROR <> 0) GOTO ERR_HANDLER
commit transaction
ERR_HANDLER:
BEGIN
ROLLBACK TRAN
End
End
ganesh.dks
7-Jun-14 11:12am
View
It wont work, throws the following error:-
Msg 245, Level 16, State 1, Procedure AssignRoleToUser, Line 6
Conversion failed when converting the varchar value '11,12,13,14,15' to data type int.
The UserID is a comma separated string.
Show More