Showing posts with label logged. Show all posts
Showing posts with label logged. Show all posts

Monday, March 19, 2012

assigning values to parameters dynamically

i using a bound data grid which is using a stored proc. The stored proc needs the ClientID "if logged in" there is no form or control on the page outside of the loginstatus. I am wanting to pass theMembership.GetUser.ProviderUserKey.ToString() to the asp:parameter but I cant get it to work.

So How do I pass a variable to a stored proc parameter using a bound data grid.

I this its very strange that this cant be dont and there are a raft of reason why you wold want to do this with out the need to pass it to a form control.

please help

jim

Add the parameter to you parameters collection as a normal asp:parameter, then hook up to the data-source control's Inserting/Updating evnet (I assume you use a data-source control with the grid) and use the event argument to get access to the command object's parameters collection (if you use SqlDataSource), or the InputParameters if you use the ObjectDataSource.|||Or alternatively, when the user authenticates, store their id in a session variable, then anywhere in your app you can add it as a session parameter.

Sunday, March 11, 2012

assigning user to a database programmatically

Environment : vc.net , SQL Server
Hi All,
I have programmatically created an SQL Server database
by executing the script file for it. I have logged in as administrator
for creating the above database in my vc.net code using SQL APIs.
Now i need to assign a new user and pasword to this database
i have created in my program. Is there a way to do it ?
Regards,
Asif
Use sp_addlogin for adding the login to the database, then use sp_grantdbaccess to grant your user access to the database. If you then want to add the user to a role use sp_addrolemember
hth,
Lance

assigning user to a database programmatically

Environment : vc.net , SQL Server
Hi All,
I have programmatically created an SQL Server database
by executing the script file for it. I have logged in as administrator
for creating the above database in my vc.net code using SQL APIs.
Now i need to assign a new user and pasword to this database
i have created in my program. Is there a way to do it ?
Regards,
AsifUse sp_addlogin for adding the login to the database, then use sp_grantdbacc
ess to grant your user access to the database. If you then want to add the
user to a role use sp_addrolemember
hth,
Lance