<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>redaware &#187; VB.NET</title>
	<atom:link href="http://www.redaware.net/tag/vb-net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.redaware.net</link>
	<description></description>
	<lastBuildDate>Thu, 09 Sep 2010 15:06:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>VB.NET Code Snippets: Updating a data source using an event</title>
		<link>http://www.redaware.net/2009/09/vb-net-code-snippets-updating-a-data-source-using-an-event/</link>
		<comments>http://www.redaware.net/2009/09/vb-net-code-snippets-updating-a-data-source-using-an-event/#comments</comments>
		<pubDate>Mon, 07 Sep 2009 13:14:18 +0000</pubDate>
		<dc:creator>tsymonds</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://www.redaware.net/?p=103</guid>
		<description><![CDATA[You may wish to update a data source using an event. 'You need to use FindControl to access control on a FormView: Dim FirstName As TextBox = FormView1.FindControl(&#34;FirstNameTextBox&#34;) Dim LastName As TextBox = FormView1.FindControl(&#34;LastNameTextBox&#34;) Dim Phone As TextBox = FormView1.FindControl(&#34;PhoneTextBox&#34;) Dim Email As TextBox = FormView1.FindControl(&#34;EmailTextBox&#34;) SqlDataSource1.InsertParameters(&#34;FirstName&#34;).DefaultValue = FirstName SqlDataSource1.InsertParameters(&#34;LastName&#34;).DefaultValue = LastName SqlDataSource1.InsertParameters(&#34;Phone&#34;).DefaultValue = Phone [...]]]></description>
			<content:encoded><![CDATA[<p>You may wish to update a data source using an event.</p>
<pre class="brush: vb;">
'You need to use FindControl to access control on a  FormView:
Dim FirstName As TextBox = FormView1.FindControl(&quot;FirstNameTextBox&quot;)
Dim LastName As TextBox = FormView1.FindControl(&quot;LastNameTextBox&quot;)
Dim Phone As TextBox = FormView1.FindControl(&quot;PhoneTextBox&quot;)
Dim Email As TextBox = FormView1.FindControl(&quot;EmailTextBox&quot;)
SqlDataSource1.InsertParameters(&quot;FirstName&quot;).DefaultValue = FirstName
SqlDataSource1.InsertParameters(&quot;LastName&quot;).DefaultValue = LastName
SqlDataSource1.InsertParameters(&quot;Phone&quot;).DefaultValue = Phone
SqlDataSource1.InsertParameters(&quot;Email&quot;).DefaultValue = Email
SqlDataSource1.Insert()
</pre>
<p>And, this is the code for Update:</p>
<pre class="brush: vb;">
SqlDataSource1.UpdateParameters(&quot;FirstName&quot;).DefaultValue = FirstName
SqlDataSource1.UpdateParameters(&quot;LastName&quot;).DefaultValue = LastName
SqlDataSource1.UpdateParameters(&quot;Phone&quot;).DefaultValue = Phone
SqlDataSource1.UpdateParameters(&quot;Email&quot;).DefaultValue = Email
SqlDataSource1. Update()
</pre>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-knowledge">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://www.redaware.net/2009/09/vb-net-code-snippets-updating-a-data-source-using-an-event/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=VB.NET+Code+Snippets%3A+Updating+a+data+source+using+an+event+-+http://b2l.me/kfutr&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.redaware.net/2009/09/vb-net-code-snippets-updating-a-data-source-using-an-event/&amp;t=VB.NET+Code+Snippets%3A+Updating+a+data+source+using+an+event" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://www.redaware.net/2009/09/vb-net-code-snippets-updating-a-data-source-using-an-event/&amp;title=VB.NET+Code+Snippets%3A+Updating+a+data+source+using+an+event&amp;summary=You%20may%20wish%20to%20update%20a%20data%20source%20using%20an%20event.%0D%0A%0D%0A%5Bcode%20lang%3D%22vb%22%5D%0D%0A%27You%20need%20to%20use%20FindControl%20to%20access%20control%20on%20a%20%20FormView%3A%0D%0ADim%20FirstName%20As%20TextBox%20%3D%20FormView1.FindControl%28%26quot%3BFirstNameTextBox%26quot%3B%29%0D%0ADim%20LastName%20As%20TextBox%20%3D%20FormView1.FindControl%28%26quot%3BLastNameTextBox%26quot%3B%29%0D%0ADim%20&amp;source=redaware" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.redaware.net/2009/09/vb-net-code-snippets-updating-a-data-source-using-an-event/&amp;title=VB.NET+Code+Snippets%3A+Updating+a+data+source+using+an+event" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.redaware.net/2009/09/vb-net-code-snippets-updating-a-data-source-using-an-event/&amp;title=VB.NET+Code+Snippets%3A+Updating+a+data+source+using+an+event" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.redaware.net/2009/09/vb-net-code-snippets-updating-a-data-source-using-an-event/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.redaware.net/2009/09/vb-net-code-snippets-updating-a-data-source-using-an-event/&amp;title=VB.NET+Code+Snippets%3A+Updating+a+data+source+using+an+event" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.redaware.net/2009/09/vb-net-code-snippets-updating-a-data-source-using-an-event/&amp;title=VB.NET+Code+Snippets%3A+Updating+a+data+source+using+an+event" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-googlebookmarks">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://www.redaware.net/2009/09/vb-net-code-snippets-updating-a-data-source-using-an-event/&amp;title=VB.NET+Code+Snippets%3A+Updating+a+data+source+using+an+event" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="shr-yahoomail">
			<a href="http://compose.mail.yahoo.com/?Subject=VB.NET+Code+Snippets%3A+Updating+a+data+source+using+an+event&amp;body=Link: http://www.redaware.net/2009/09/vb-net-code-snippets-updating-a-data-source-using-an-event/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A You%20may%20wish%20to%20update%20a%20data%20source%20using%20an%20event.%0D%0A%0D%0A%5Bcode%20lang%3D%22vb%22%5D%0D%0A%27You%20need%20to%20use%20FindControl%20to%20access%20control%20on%20a%20%20FormView%3A%0D%0ADim%20FirstName%20As%20TextBox%20%3D%20FormView1.FindControl%28%26quot%3BFirstNameTextBox%26quot%3B%29%0D%0ADim%20LastName%20As%20TextBox%20%3D%20FormView1.FindControl%28%26quot%3BLastNameTextBox%26quot%3B%29%0D%0ADim%20" rel="nofollow" class="external" title="Email this via Yahoo! Mail">Email this via Yahoo! Mail</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://www.redaware.net/2009/09/vb-net-code-snippets-updating-a-data-source-using-an-event/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VB.NET: Retrieving Active Directory account properties</title>
		<link>http://www.redaware.net/2009/08/vb-net-retrieving-active-directory-account-properties/</link>
		<comments>http://www.redaware.net/2009/08/vb-net-retrieving-active-directory-account-properties/#comments</comments>
		<pubDate>Wed, 05 Aug 2009 08:22:24 +0000</pubDate>
		<dc:creator>tsymonds</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[AD]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[Windows 2003 Server]]></category>

		<guid isPermaLink="false">http://www.redaware.net/?p=61</guid>
		<description><![CDATA[The .NET Framework includes an API called System.DirectoryServices. The sample VB.NET code below shows how to retrieve user account properties from the Active Directory. In order to use System.DirectoryServices classes, you will need to first add a reference to System.DirectoryServices. Imports System.DirectoryServices is required at the very top of your VB.NET code. Function GetUserProperties(ByVal GetUser, [...]]]></description>
			<content:encoded><![CDATA[<p>The .NET Framework includes an API called System.DirectoryServices. The sample VB.NET code below shows how to retrieve user account properties from the Active Directory.</p>
<p>In order to use System.DirectoryServices classes, you will need to first add a reference to <strong>System.DirectoryServices</strong>. </p>
<p><strong>Imports System.DirectoryServices</strong> is required at the very top of your VB.NET code.</p>
<pre class="brush: vb;">
Function GetUserProperties(ByVal GetUser, ByVal Result)
        Dim objSearch As New DirectorySearcher
        objSearch.SearchRoot = New DirectoryEntry(&quot;LDAP://dc=domain,dc=co,dc=uk&quot;)
        objSearch.Filter = GetUser
        'cn = Full Name, givenName = First name, initials = Middle names, sn = Surname, mail = email address
        objSearch.PropertiesToLoad.AddRange(New String() {&quot;cn&quot;, &quot;giveName&quot;, &quot;initials&quot;, &quot;sn&quot;, &quot;department&quot;, &quot;mail&quot;, &quot;Manager&quot;})
        Dim objResult As SearchResult
        objResult = objSearch.FindOne()
        GetUserProperties = (objResult.Properties(Result)(0))
End Function
</pre>
<p>Replace <strong>dc=domain, dc=co, dc=uk</strong> with your AD settings.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-knowledge">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://www.redaware.net/2009/08/vb-net-retrieving-active-directory-account-properties/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=VB.NET%3A+Retrieving+Active+Directory+account+properties++-+http://b2l.me/kjek7&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.redaware.net/2009/08/vb-net-retrieving-active-directory-account-properties/&amp;t=VB.NET%3A+Retrieving+Active+Directory+account+properties+" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://www.redaware.net/2009/08/vb-net-retrieving-active-directory-account-properties/&amp;title=VB.NET%3A+Retrieving+Active+Directory+account+properties+&amp;summary=The%20.NET%20Framework%20includes%20an%20API%20called%20System.DirectoryServices.%20The%20sample%20VB.NET%20code%20below%20shows%20how%20to%20retrieve%20user%20account%20properties%20from%20the%20Active%20Directory.%0D%0A%0D%0AIn%20order%20to%20use%20System.DirectoryServices%20classes%2C%20you%20will%20need%20to%20first%20add%20a%20reference%20to%20System.DirectoryServices.%20%0D%0A%0D%0AImpor&amp;source=redaware" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.redaware.net/2009/08/vb-net-retrieving-active-directory-account-properties/&amp;title=VB.NET%3A+Retrieving+Active+Directory+account+properties+" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.redaware.net/2009/08/vb-net-retrieving-active-directory-account-properties/&amp;title=VB.NET%3A+Retrieving+Active+Directory+account+properties+" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.redaware.net/2009/08/vb-net-retrieving-active-directory-account-properties/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.redaware.net/2009/08/vb-net-retrieving-active-directory-account-properties/&amp;title=VB.NET%3A+Retrieving+Active+Directory+account+properties+" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.redaware.net/2009/08/vb-net-retrieving-active-directory-account-properties/&amp;title=VB.NET%3A+Retrieving+Active+Directory+account+properties+" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-googlebookmarks">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://www.redaware.net/2009/08/vb-net-retrieving-active-directory-account-properties/&amp;title=VB.NET%3A+Retrieving+Active+Directory+account+properties+" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="shr-yahoomail">
			<a href="http://compose.mail.yahoo.com/?Subject=VB.NET%3A+Retrieving+Active+Directory+account+properties+&amp;body=Link: http://www.redaware.net/2009/08/vb-net-retrieving-active-directory-account-properties/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A The%20.NET%20Framework%20includes%20an%20API%20called%20System.DirectoryServices.%20The%20sample%20VB.NET%20code%20below%20shows%20how%20to%20retrieve%20user%20account%20properties%20from%20the%20Active%20Directory.%0D%0A%0D%0AIn%20order%20to%20use%20System.DirectoryServices%20classes%2C%20you%20will%20need%20to%20first%20add%20a%20reference%20to%20System.DirectoryServices.%20%0D%0A%0D%0AImpor" rel="nofollow" class="external" title="Email this via Yahoo! Mail">Email this via Yahoo! Mail</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://www.redaware.net/2009/08/vb-net-retrieving-active-directory-account-properties/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
