<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Visual Studio 2005 database programming?</title>
	<atom:link href="http://www.extensibles.com/77/visual-studio-database/visual-studio-2005-database-programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.extensibles.com/77/visual-studio-database/visual-studio-2005-database-programming/</link>
	<description>Performance and Optimization of SQL Server, .NET and Visual Studio</description>
	<lastBuildDate>Fri, 16 Apr 2010 20:28:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Kevin</title>
		<link>http://www.extensibles.com/77/visual-studio-database/visual-studio-2005-database-programming/comment-page-1/#comment-83</link>
		<dc:creator>Kevin</dc:creator>
		<pubDate>Fri, 16 Apr 2010 20:25:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.extensibles.com/77/visual-studio-database/visual-studio-2005-database-programming/#comment-83</guid>
		<description>hi.. this is good question

in order to resolve this problem one of the possible way is 

executing a select statement before doing the insertion in the database

create connection to the database...

so ur getting the first and last name in the text box  


Execute the following query: (use datareader to execute the query)

&quot;select * from Employee where Fname = &#039;&quot; &amp; txtFName.text &amp; &quot;&#039; and LName = &#039;&quot; &amp; txtLName &amp; &quot;&#039;&quot;

after executed the query using VS2005 in the execute reader

check 

if dr.hasrows() = true
    Msgbox(&quot;Name already exist&quot;)
else
    &lt;your insert statement&gt;
endif

so u can prevent the duplication of the first and last name
if u want check only the first or last name provide that one in the select query which u want to check


sample Example: for checking username and password 

dim  theOleDbCommand = new OleDbCommand(&quot;SELECT [ID] FROM tableName WHERE username = &#039;&quot; + this.txtUserName.Text + &quot;&#039; AND [Password] = &#039;&quot; + this.txtPassword.Text + &quot;&#039;&quot;);

theOleDbCommand.Connection = new OleDbConnection(connectionStringHere);

theOleDbCommand.Connection.Open();

dim theReader = theOleDbCommand.ExecuteReader(CommandBehavior.CloseConnection);

//you may need to comment out the line below, experiment:

//theReader.Read();

if (theReader.HasRows) then
{

   //they logged in, data exists

}

else

{

   //error, they don&#039;t exist or the username/password is invalid

}

theOleDbCommand.Connection.Close();&lt;/your&gt;</description>
		<content:encoded><![CDATA[<p>hi.. this is good question</p>
<p>in order to resolve this problem one of the possible way is </p>
<p>executing a select statement before doing the insertion in the database</p>
<p>create connection to the database&#8230;</p>
<p>so ur getting the first and last name in the text box  </p>
<p>Execute the following query: (use datareader to execute the query)</p>
<p>&#8220;select * from Employee where Fname = &#8216;&#8221; &#038; txtFName.text &#038; &#8220;&#8216; and LName = &#8216;&#8221; &#038; txtLName &#038; &#8220;&#8216;&#8221;</p>
<p>after executed the query using VS2005 in the execute reader</p>
<p>check </p>
<p>if dr.hasrows() = true<br />
    Msgbox(&#8220;Name already exist&#8221;)<br />
else<br />
    <your insert statement><br />
endif</p>
<p>so u can prevent the duplication of the first and last name<br />
if u want check only the first or last name provide that one in the select query which u want to check</p>
<p>sample Example: for checking username and password </p>
<p>dim  theOleDbCommand = new OleDbCommand(&#8220;SELECT [ID] FROM tableName WHERE username = &#8216;&#8221; + this.txtUserName.Text + &#8220;&#8216; AND [Password] = &#8216;&#8221; + this.txtPassword.Text + &#8220;&#8216;&#8221;);</p>
<p>theOleDbCommand.Connection = new OleDbConnection(connectionStringHere);</p>
<p>theOleDbCommand.Connection.Open();</p>
<p>dim theReader = theOleDbCommand.ExecuteReader(CommandBehavior.CloseConnection);</p>
<p>//you may need to comment out the line below, experiment:</p>
<p>//theReader.Read();</p>
<p>if (theReader.HasRows) then<br />
{</p>
<p>   //they logged in, data exists</p>
<p>}</p>
<p>else</p>
<p>{</p>
<p>   //error, they don&#8217;t exist or the username/password is invalid</p>
<p>}</p>
<p>theOleDbCommand.Connection.Close();</your></p>
]]></content:encoded>
	</item>
</channel>
</rss>

