Skip to main content

Posts

Showing posts from June, 2009

Using Variable in Openrowset

u can add something variable in Openrowset to provide "Provider", "Connection", "Query" use something like this DECLARE @Query NVARCHAR(4000) SET @Query = 'SELECT ''Please Select'' AS [Department] UNION ALL SELECT [Department] FROM OPENROWSET( ''SQLNCLI'', ''' + @ConnectionString + ''', ''EXEC SPROC_NAME_HERE'') EXEC (@Query) where the @Connectionstring are Server=SERVER_NAME\INSTANCE_NAME;UID=USER_ID;PWD=PASSWORD;Database=DATABASE;'

UserControl in WebPart

some of you maybe get used of using Web Part extension in Visual Studio Project and build the UI using code without the UI there but i found a simple alternative using User Control and in the Web Part is just some code to load that UserControl. U can debug ur code and it's with UI :D here is what i'm doing.. User Control Project: 1. Create New ASP.NET Web Application. 2. Add New User Control into the Project. 3. Design your User Control, u can add code behind or anything like that. 4. Test the User Control by dragging it to Default.aspx page that automatically created from step 1. 5. Build your Application for the last time (it will have .dll inside bin folder of your application). for now we leave the User Control Project, we go on making our Web Part Object 1. Create New Web Part Project, 2. You can delete the default Webpart project that created then create new one to suit the name or u can use the existing one. 3. Add reference to Microsoft.Sharepoint.dll 4. Add some direct

Imports Users in Active Directory to SQL Server

' Bind to RootDSE - this object is used to ' get the default configuration naming context ' e.g. dc=wisesoft,dc=co,dc=uk set objRootDSE = getobject("LDAP://RootDSE") ' Root of search set to default naming context. ' e.g. dc=wisesoft,dc=co,dc=uk ' RootDSE saves hard-coding the domain. ' If want to search within an OU rather than the domain, ' specify the distinguished name of the ou. e.g. ' ou=students,dc=wisesoft,dc=co,dc=uk" strRoot = objRootDSE.Get("DefaultNamingContext") ' Filter for user accounts - could be modified to search for specific users, ' such as those with mailboxes, users in a certain department etc. strfilter = "(&(objectCategory=Person)(objectClass=User))" ' Attributes to return from the query strAttributes = "sAMAccountName,userPrincipalName,givenName,sn," & _ "displayName,mail, " & _ "title,department," & _ "manager" '