tag:blogger.com,1999:blog-62158444756379700912024-03-23T03:14:29.478-07:00VB.NET Sample codeThis blog contain vb.net sample code base on vs2005, sql script and another.Unknownnoreply@blogger.comBlogger53125tag:blogger.com,1999:blog-6215844475637970091.post-80948995513246361792013-01-27T23:27:00.000-08:002013-01-27T23:27:14.055-08:00Microsoft Visual Studio Pro 2012<div style="text-align: center;">
<iframe frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://rcm.amazon.com/e/cm?lt1=_blank&bc1=FFFFFF&IS2=1&npa=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=vb.net-book-developers-20&o=1&p=8&l=as1&m=amazon&f=ifr&ref=tf_til&asins=B008RW3XIO" style="height: 240px; width: 120px;"></iframe>
</div>
<div style="text-align: center;">
<br /></div>
<h1 class="parseasinTitle " style="background-color: white; font-family: Arial, Helvetica, sans-serif; font-size: 1.7em; font-weight: normal; margin-bottom: 0px; margin-top: 0px;">
</h1>
<h2 style="color: #cc6600; font-family: verdana, arial, helvetica, sans-serif; font-size: medium; margin: 0px 0px 0.25em;">
<a href="http://www.blogger.com/"></a><span id="goog_712982434"></span><span id="goog_712982435"></span></h2>
<h2 style="color: #cc6600; font-family: verdana, arial, helvetica, sans-serif; font-size: medium; margin: 0px 0px 0.25em;">
</h2>
<h2 style="color: #cc6600; font-family: verdana, arial, helvetica, sans-serif; font-size: medium; margin: 0px 0px 0.25em; text-align: center;">
Product Features</h2>
<div>
<br /></div>
<div class="content" style="font-family: verdana, arial, helvetica, sans-serif; font-size: small; margin: 0.5em 0px 0em 25px;">
<ul style="margin: 0px 0px 0px 25px; padding: 0px;">
<li style="margin: 0.5em 0em;">Deep interoperability with business and consumer platforms lets you build what your users want, where they want it</li>
<li style="margin: 0.5em 0em;">Create apps in a streamlined UI where common tasks are presented in a fresh, integrated development experience</li>
<li style="margin: 0.5em 0em;">Consolidate many development tasks into one tool so you can enhance existing apps or build new modern ones</li>
<li style="margin: 0.5em 0em;">Requirements: Processor - 1.6GHz+ CPUOS - Windows 8 (x86/x64), Windows 7 SP1 (x86/x64), Windows Server 2008 R2 SP1 (x64), Windows Server 2012 (x64)Memory(RAM) - 1GB (1.5GB if running on a virtual machine.</li>
</ul>
<div>
<br /></div>
<div>
<br /></div>
<div>
<span style="color: #666666; font-family: 'Segoe UI Semibold', Arial, sans-serif; font-size: 16px; line-height: 22px;">Why buy Visual Studio Professional with MSDN?</span></div>
<div>
<div style="border: 0px; clear: both; color: #666666; font-family: 'Segoe UI', Tahoma, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 24px; outline: 0px; padding: 0px; vertical-align: baseline;">
Software development doesn’t stand still—you push the technology envelope one day, and then need yesterday’s platforms and tools to support legacy apps the next. Visual Studio Professional with MSDN gives you access to Microsoft platforms and tools from the past and present, with new releases being added all the time. Plus, since it includes Team Foundation Server, you get the tools you need to work well with others. And now you have services to take your apps to the cloud, Windows Store, and Windows Phone Marketplace. Get Visual Studio Professional with MSDN and raise your development game.</div>
<div style="border: 0px; clear: both; color: #666666; font-family: 'Segoe UI', Tahoma, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 24px; outline: 0px; padding: 0px; vertical-align: baseline;">
<br /></div>
<div style="border: 0px; clear: both; color: #666666; font-family: 'Segoe UI', Tahoma, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 24px; outline: 0px; padding: 0px; vertical-align: baseline;">
<br /></div>
</div>
</div>
Unknownnoreply@blogger.com22tag:blogger.com,1999:blog-6215844475637970091.post-36279506083096618372011-12-12T18:21:00.001-08:002011-12-12T19:07:30.314-08:00Read excel to dataset<div><span class="Apple-style-span">This sample show how to read data from excel file by using Microsoft.Jet.OLEDB.</span></div><div><span class="Apple-style-span"><br /></span></div><div><span class="Apple-style-span">More information about excel connectionstring see <a href="http://www.connectionstrings.com/excel">http://www.connectionstrings.com/excel</a></span></div><div><span class="Apple-style-span"><br /></span></div><div><span class="Apple-style-span">Let's sample code.</span></div><div><span class="Apple-style-span"><br /></span></div><div><span class="Apple-style-span"> Private Function ReadExcelFile(ByVal filePath As String, ByVal fileName As String) As DataSet</span></div><div><span class="Apple-style-span"> '' Excel 2003</span></div><div><span class="Apple-style-span"> Dim sConn As String = String.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0}", filePath + fileName)</span></div><div><span class="Apple-style-span"> sConn += ";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1;"""</span></div><div><span class="Apple-style-span"><br /></span></div><div><span class="Apple-style-span"> 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyExcel.xls;Extended Properties="Excel 8.0;HDR=Yes;IMEX=1";</span></div><div><span class="Apple-style-span"><br /></span></div><div><span class="Apple-style-span"> Dim sSql As String = "SELECT * FROM [Sheet1$]"</span></div><div><span class="Apple-style-span">'Select excel range command</span></div><div><span class="Apple-style-span" >' Dim sSql As String = "SELECT * FROM <span class="Apple-style-span">[Sheet1$A1:D3]</span>"</span></div><div><span class="Apple-style-span"><br /></span></div><div><span class="Apple-style-span"> Dim pFile As New FileInfo(fileName)</span></div><div><span class="Apple-style-span"> If (pFile.Extension.ToLower() = ".xlsx") Then</span></div><div><span class="Apple-style-span"> ' Excel 2007</span></div><div><span class="Apple-style-span"> sConn = String.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0}", filePath + fileName)</span></div><div> </div><div><span class="Apple-style-span"> sConn += ";Extended Properties=""Excel 12.0 Xml;HDR=YES;"""</span></div><div><span class="Apple-style-span"> End If</span></div><div><span class="Apple-style-span"><br /></span></div><div><span class="Apple-style-span"><br /></span></div><div><span class="Apple-style-span"> Dim ds As New DataSet</span></div><div><span class="Apple-style-span"> Dim pConn As New OleDbConnection(sConn)</span></div><div><span class="Apple-style-span"> Try</span></div><div><span class="Apple-style-span"> pConn.Open()</span></div><div><span class="Apple-style-span"> Dim pCmd As New OleDbCommand()</span></div><div><span class="Apple-style-span"> pCmd.Connection = pConn</span></div><div><span class="Apple-style-span"> pCmd.CommandText = sSql</span></div><div><span class="Apple-style-span"><br /></span></div><div><span class="Apple-style-span"> Dim pAdp As New OleDbDataAdapter()</span></div><div><span class="Apple-style-span"> pAdp.SelectCommand = pCmd</span></div><div><span class="Apple-style-span"><br /></span></div><div><span class="Apple-style-span"> pAdp.Fill(ds)</span></div><div><span class="Apple-style-span"> Catch ex As Exception</span></div><div><span class="Apple-style-span"> Return Nothing</span></div><div><span class="Apple-style-span"> Finally</span></div><div><span class="Apple-style-span"> pConn.Close()</span></div><div><span class="Apple-style-span"> End Try</span></div><div><span class="Apple-style-span"><br /></span></div><div><span class="Apple-style-span"> Return ds</span></div><div><span class="Apple-style-span"> End Function</span></div><div><span class="Apple-style-span"><br /></span></div><div><span class="Apple-style-span"><b>Note</b></span></div><div>If found error<i> Could not find installable ISAM </i>that mean your connectionstring was wrong.</div><div><br /></div><div><br /></div><div id="-chrome-auto-translate-plugin-dialog" style="opacity: 1 !important; background-image: initial !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: transparent !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; position: absolute !important; top: 0px; left: 0px; overflow-x: visible !important; overflow-y: visible !important; z-index: 999999 !important; text-align: left !important; display: none; background-position: initial initial !important; background-repeat: initial initial !important; "><div style="max-width: 300px !important;color: #fafafa !important;opacity: 0.8 !important;border-color: #000000 !important;border-width: 0px !important;-webkit-border-radius: 10px !important;background-color: #363636 !important;font-size: 16px !important;padding: 8px !important;overflow: visible !important;background-image: -webkit-gradient(linear, left top, right bottom, color-stop(0%, #000), color-stop(50%, #363636), color-stop(100%, #000));z-index: 999999 !important;text-align: left !important;"><div class="translate"></div><div class="additional"></div></div><img src="http://www.google.com/uds/css/small-logo.png" style="position: absolute !important; z-index: -1 !important; right: 1px !important; top: -20px !important; cursor: pointer !important;-webkit-border-radius: 20px; background-color: rgba(200, 200, 200, 0.3) !important; padding: 3px 5px 0 !important; margin: 0 !important;" onclick="document.location.href='http://translate.google.com/';" /></div>Unknownnoreply@blogger.com20tag:blogger.com,1999:blog-6215844475637970091.post-20798254535787230382011-06-21T22:22:00.000-07:002011-06-21T23:51:49.268-07:00ListView1. Design ListView like this picture.<br /><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhESOdhAjog__6H1ewLpkjHz9eJL52N7mAfz8lqXjE14eF04hxDVoeT7M7D80uug7upGBbjx84DKu5u6Qp4pzb_3XLkaq1nybBeGzQKt0N2JRoT1xWMbDuXu6mO_zbkDRK11PNMlq41VzU/s1600/listview1.png"><img style="WIDTH: 320px; HEIGHT: 103px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5620906000550195842" border="0" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhESOdhAjog__6H1ewLpkjHz9eJL52N7mAfz8lqXjE14eF04hxDVoeT7M7D80uug7upGBbjx84DKu5u6Qp4pzb_3XLkaq1nybBeGzQKt0N2JRoT1xWMbDuXu6mO_zbkDRK11PNMlq41VzU/s320/listview1.png" /></a><br /><br />2. Set Listview property<br /><br />FullRowSelect = True<br />GridLines = True<br />UseCompatibleStateImageBehavior = False<br />View = Details<br /><br />3. Using System.Windows.Forms.ListView<br /><br />4. Sample code to add item to listview (When click button add item to listview)<br />Dim pObj <span style="color:#3333ff;">As</span> New ListViewItem("Code")<br />pObj.SubItems.<span style="color:#3333ff;">Add</span>("Item Name")<br />pObj.SubItems.<span style="color:#3333ff;">Add</span>("10.00")<br />pObj.SubItems.<span style="color:#3333ff;">Add</span>("1")<br />pObj.SubItems.<span style="color:#3333ff;">Add</span>("1.50"))<br />pObj.SubItems.<span style="color:#3333ff;">Add</span>("15.00")<br />pObj.Tag = 1 <span style="color:#cc0000;">' keep materail id ListView1.Items.Add(pObj)<br /></span><br />5. Sample code to delete item in listview when press delete on keyboard.<br /><span style="color:#3333ff;">Private </span>Sub ListView1_KeyUp(ByVal sender As System.Object, ByVal e <span style="color:#3333ff;">As System.Windows</span>.Forms.KeyEventArgs) Handles lstMaterial.KeyUp<br /><span style="color:#3333ff;">If </span>e.KeyCode = Keys.<span style="color:#3333ff;">Delete</span> AndAlso ListView1.SelectedItems.<span style="color:#cc33cc;">Count</span> > 0 <span style="color:#3333ff;">Then</span><br /><span style="color:#3333ff;">For</span> i <span style="color:#3333ff;">As Integer</span> = ListView1.SelectedItems.<span style="color:#cc33cc;">Count</span> - 1 To 0 Step -1<br />ListView1.Items.RemoveAt(ListView1.SelectedItems(i).<span style="color:#3333ff;">Index</span>)<br /><span style="color:#3333ff;">Next</span><br /><span style="color:#3333ff;">End If</span><br /><span style="color:#3333ff;">End</span> SubUnknownnoreply@blogger.com6tag:blogger.com,1999:blog-6215844475637970091.post-60498159949847716022010-02-23T19:35:00.000-08:002010-02-23T19:58:01.306-08:00Send Email By SMTP<span style=";font-family:'Courier New';color:blue;" >Imports</span> System.Net.Mail<br /><p class="MsoNormal" style="margin: 0cm 0cm 0pt;" align="left"><span style="font-size:85%;"><span style="font-family:'Courier New';"><span dtid="562949953421322" style="color:blue;"><br />Public</span> <span dtid="562949953421323" style="color:blue;">Sub</span> SendEmail()</span></span></p><blockquote style="margin-top: 0px; margin-bottom: 0px;"><p align="left"><span style="font-size:85%;"><span dtid="562949953421325" style="font-family:'Courier New';"><span dtid="562949953421326" style="color:blue;">Dim</span> client <span dtid="562949953421327" style="color:blue;">As</span> <span dtid="562949953421328" style="color:blue;">New</span> SmtpClient()</span><span style="font-family:Times New Roman;"><br /></span></span><span style="font-size:85%;"><span dtid="562949953421338" style="font-family:'Courier New';"><span dtid="562949953421333" style="color:blue;">Dim</span> sendTo <span dtid="562949953421334" style="color:blue;">As</span> <span dtid="562949953421335" style="color:blue;">New</span> MailAddress("<span style="color: rgb(163, 21, 21);" dtid="562949953421336"><a href="mailto:sendToAccount@gmail.com"><span style="color: rgb(102, 0, 0);"><span style="color: rgb(153, 51, 0);">sendToAccount</span></span><span style="color: rgb(153, 51, 0);">@gmail.com</span></a>"</span>)<span dtid="562949953421339" style="color:blue;"><br />Dim <span style="color: rgb(0, 0, 0);">from</span> As <span style="color: rgb(0, 0, 0);">MailAddress</span> = New <span style="color: rgb(0, 0, 0);">MailAddress</span>("<span style="color: rgb(153, 51, 0);">from@address.com</span>")<br />Dim</span> message <span dtid="562949953421340" style="color:blue;">As</span> <span dtid="562949953421341" style="color:blue;">New</span> MailMessage(from,sendTo)</span><br /></span><span style="font-size:85%;"><br /></span><span style="font-size:85%;"><span dtid="562949953421357" style="font-family:'Courier New';">message.IsBodyHtml = <span dtid="562949953421352" style="color:blue;">True</span><br />message.Subject = <span style="color: rgb(163, 21, 21);" dtid="562949953421355">"Test SMTP"</span><br />message.Body = <span style="color: rgb(163, 21, 21);" dtid="562949953421358">"Got it!!"</span></span> </span></p><p class="MsoNormal" dtid="562949953421364" align="left"><span style="font-size:85%;"><span dtid="562949953421362" style="font-family:'Courier New';"><span dtid="562949953421363" style="color:green;">' Use the same account in app.config to authenticate.</span></span><br /><span dtid="562949953421365" style="font-family:'Courier New';"><span dtid="562949953421366" style="color:blue;">Dim</span> basicAuthenticationInfo <span dtid="562949953421367" style="color:blue;">As</span> <span dtid="562949953421368" style="color:blue;">New</span> System.Net.NetworkCredential(<span style="color: rgb(163, 21, 21);" dtid="562949953421369">"yourAccount@xxx.com"</span>, <span style="color: rgb(163, 21, 21);" dtid="562949953421370">"YourPassword"</span>)</span></span></p><p class="MsoNormal" dtid="562949953421364" align="left"><span style="font-size:85%;"><span dtid="562949953421374" style="font-family:'Courier New';"><br />client.Host = "smtp.xxx.com" <br />client.UseDefaultCredentials = <span dtid="562949953421375" style="color:blue;">False</span></span><br /><span dtid="562949953421377" style="font-family:'Courier New';">client.Credentials = basicAuthenticationInfo</span></span></p><p class="MsoNormal" dtid="562949953421364" align="left"><span style="font-size:85%;"><span dtid="562949953421379" style="font-family:'Courier New';"><span style="color: rgb(0, 153, 0);">'' For smtp config<br />'' google use<span style="font-style: italic;"><span style="font-weight: bold;"> </span></span>EnableSsl=True and Port = 587<br /></span></span></span><span style="font-size:85%;"><span dtid="562949953421379" style="font-family:'Courier New';"><br /><span style="font-style: italic; font-weight: bold;">client.EnableSsl = </span><span style="font-style: italic; font-weight: bold;color:blue;" dtid="562949953421380" >False<br /></span></span></span><span style="font-style: italic; font-weight: bold;font-size:85%;" ><span dtid="562949953421377" style="font-family:'Courier New';">client.Port = 25</span></span><br /></p><p class="MsoNormal" dir="ltr" style="margin-right: 0px;" dtid="562949953421388" align="left"><span dtid="562949953421387"><span style="font-family:Courier New;"><span dtid="562949953421385" style=";font-size:85%;color:blue;" >Try</span></span></span></p><blockquote style="margin-top: 0px; margin-bottom: 0px;"><p class="MsoNormal" dir="ltr" style="margin-right: 0px;" dtid="562949953421388" align="left"><span style="font-size:85%;"><span dtid="562949953421387"><span style="font-family:Courier New;">client.Send(message)<br /></span></span><span dtid="562949953421398" style="font-family:Courier New;">Console.WriteLine(<span style="color: rgb(163, 21, 21);" dtid="562949953421392">"SUCCESS"</span>)</span></span></p></blockquote><span dtid="562949953421398" style="font-family:Courier New;"><p class="MsoNormal" dir="ltr" style="margin-right: 0px;" dtid="562949953421388" align="left"><span style="font-size:85%;"><span dtid="562949953421395" style="color:blue;">Catch</span> ex <span dtid="562949953421396" style="color:blue;">As</span> Exception</span></p></span><blockquote style="margin-top: 0px; margin-bottom: 0px;"><p class="MsoNormal" dir="ltr" style="margin-right: 0px;" dtid="562949953421388" align="left"><span style=";font-family:Courier New;font-size:85%;" >Console.WriteLine(<span style="color: rgb(163, 21, 21);" dtid="562949953421399">"SEND FAIL"</span>)</span></p></blockquote><p class="MsoNormal" dir="ltr" style="margin-right: 0px;" dtid="562949953421388" align="left"><span dtid="562949953421407" style="font-family:'Courier New';"><span style="font-size:85%;"><span dtid="562949953421404" style="color:blue;">End</span> <span dtid="562949953421405" style="color:blue;">Try</span></span></span></p></blockquote><p class="MsoNormal" dir="ltr" dtid="562949953421408" align="left"><span style="font-size:85%;"><span dtid="562949953421409" style="font-family:'Courier New';"><span dtid="562949953421410" style="color:blue;">End</span> <span dtid="562949953421411" style="color:blue;">Sub</span></span></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family:Times New Roman;"></span></p><p class="MsoNormal" dtid="562949953421408"><span dtid="562949953421409" style="font-family:'Courier New';"><span style="font-size:8px;"><span dtid="562949953421411" style="color:blue;"></span></span></span></p>Unknownnoreply@blogger.com22tag:blogger.com,1999:blog-6215844475637970091.post-53782524708669691812010-02-22T20:56:00.000-08:002010-02-22T21:27:20.234-08:00Developer Books<div style="text-align: center;">Developer Books<br /></div><br /><div style="text-align: center;"><a href="http://www.amazon.com/gp/product/0470191368?ie=UTF8&tag=vbnesaco-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=0470191368"><img src="http://www.ampmubook.com/51sAmbHrswL._SL160_.jpg" border="0" /></a><img src="http://www.assoc-amazon.com/e/ir?t=vbnesaco-20&l=as2&o=1&a=0470191368" alt="" style="border: medium none ! important; margin: 0px ! important;" width="1" border="0" height="1" /><br /></div><br /><div style="text-align: center;"><u>Professional Visual Basic 2008 (Programmer to Programmer)</u><br /></div><br />* Paperback: 1420 pages<br />* Publisher: Wrox (May 5, 2008)<br />* Language: English<br />* ISBN-10: 0470191368<br />* ISBN-13: 978-0470191361<br /><br />Product Description<br />Professional Visual Basic 2008<br /><br />The 2008 version of Visual Basic is tremendously enhanced and introduces dramatic new concepts, techniques, and features to this popular object-oriented language. Written by an elite author team who are sympathetic to the challenges of learning VB 2008, this comprehensive book provides a clear and concise approach to using VB 2008 in the ever-expanding .NET world.<br /><br />This book focuses on using the latest and most powerful tools from the Microsoft arsenal within your Visual Basic solutions. Looking closely at LINQ, AJAX, a new Visual Studio and more, you'll be able to take lessons from this book and apply them to what you are doing today. You'll examine everything from the .NET Framework to the best practices for deploying .NET applications to database access and integrating with other technologies, such as COM and XML.<br /><br />What you will learn from this book<br /><br />* The core elements of VB 2008 as well as full syntax of all the new additions the language offers<br />* Ways that the Common Language Runtime (CLR) is responsible for managing the execution of code compiled on the .NET platform<br />* How VB is used in the creation, installation, running, and debugging of Windows? Services<br />* How to work with the new SQL Server 2008 along with your .NET applications<br />* The many features of Windows Forms and Windows Presentation Foundation<br />* Ways to take advantage of the abilities of LINQ<br />* The new web technology introduced by Silverlight<br /><br />Who this book is for<br /><br />This book is for experienced developers who are looking to transition to the latest version of Visual Basic.<br /><br />Wrox Professional guides are planned and written by working programmers to meet the real-world needs of programmers, developers, and IT professionals. Focused and relevant, they address the issues technology professionals face every day. They provide examples, practical solutions, and expert education in new technologies, all designed to help programmers do a better job.<br /><br /><hr /><br /><div style="text-align: center;"><a href="http://www.amazon.com/gp/product/073561931X?ie=UTF8&tag=vb.net-book-developers-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=073561931X"><img src="http://www.ampmubook.com/41kDLQeE8vL._SL160_.jpg" border="0" /></a><img src="http://www.assoc-amazon.com/e/ir?t=vb.net-book-developers-20&l=as2&o=1&a=073561931X" alt="" style="border: medium none ! important; margin: 0px ! important;" width="1" border="0" height="1" /><br /><br /><u><span style="font-weight: bold;">Microsoft Visual Basic .NET Programmer's Cookbook (Pro-Developer)</span></u><br /></div><br />Finally, a book with one-stop shopping for VB.NET! I’ve read several cookbook-style programming titles in the past, and I was pleasantly surprised to find this has much more depth than I expected. It can’t cover everything (.NET is huge), but every time I pick the book up I learn something new. There are so many highlights–just browse through the table of contents and you’ll see what I mean!<br />Here are some of my favorites:<br />* Send keystrokes to another app<br />* Create a thread-safe control wrapper<br />* Great data-binding tips (image-to-picture box, etc.)<br />* Factory, Registry, Singleton, Memento, and Lazy Initialization patterns<br />* POP3, FTP, and Ping classes in the networking section<br />* How to change a password into a salted hash for storage in a database<br />* Use ZIP and PDF files (disclaimer: some third-party code is required, although it’s free)<br />* Manage print jobs that are underway<br />* Get Windows accounts and roles<br />* Do hit testing with custom graphics<br />* Defend against SQL injection<br />* Dynamically generate an ASP.NET graphic<br />* Add ASP.NET controls on the fly<br />* MAPI and MCI (unfortunately, just through the ActiveX controls)<br />* Upload binary data with a web service<br />* Use a web service in VB 6<br /><br /><span>Written by </span> <a onclick="Track.click('/Article/Geek/Byline/author')" href="http://www.zimbio.com/member/cellphonereview">cellphonereview</a> on <script type="text/javascript">document.write(localTime('1261404503000'));</script>Dec-21-09 9:08pm<noscript>2009-12-21T06:08:23</noscript> <div class="sourceLine"> <span>From:</span> <a class="wine" onclick="Track.click('/Blog+Link/Geek/Byline/bestdp.com')" href="http://bestdp.com/microsoft-visual-basic-net-programmers-cookbook-review-paperback.html">bestdp.com</a> </div><br /><br /><hr /><div style="text-align: center; font-weight: bold;"><br /></div><div style="text-align: center;"><a href="http://www.amazon.com/gp/product/0735626022?ie=UTF8&tag=vb.net-book-developers-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=0735626022"><img src="http://www.ampmubook.com/51gksDhxImL._SL160_.jpg" border="0" /></a><img src="http://www.assoc-amazon.com/e/ir?t=vb.net-book-developers-20&l=as2&o=1&a=0735626022" alt="" style="border: medium none ! important; margin: 0px ! important;" width="1" border="0" height="1" /><br /><br /><u><span style="font-weight: bold;">Inside Microsoft SQL Server 2008: T-SQL Programming (Pro-Develper) </span> </u><br /><br /></div><strong>Product Description</strong><br />Tackle the toughest set-based querying and query tuning problems—guided by an author team with in-depth, inside knowledge of T-SQL. Deepen your understanding of architecture and internals—and gain practical approaches and advanced techniques to optimize your code’s performance. <strong>Discover how to:</strong><br />* Move from procedural programming to the language of sets and logic<br />* Optimize query tuning with a top-down methodology<br />* Assess algorithmic complexity to predict performance<br />* Compare data-aggregation techniques, including new grouping sets<br />* Manage data modification—insert, delete, update, merge—for performance<br />* Write more efficient queries against partitioned tables<br />* Work with graphs, trees, hierarchies, and recursive queries<br />* Plus—Use pure-logic puzzles to sharpen your problem-solving skillsUnknownnoreply@blogger.com8tag:blogger.com,1999:blog-6215844475637970091.post-54891510848135338652009-10-29T01:24:00.000-07:002009-10-29T02:26:30.735-07:00Show and Hide Windows Form in System Tray<span style="font-weight: bold;">How to show and hide your form in windows system tray.</span><br /><br />1. Add NotifyIcon class in your project (System.Windows.Forms.NotifyIcon) and drag it into form.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSuGnj7aIp0vT9LdFpHZiYJ2Dz_hTFOuAWc9EZOcYq7bBvG6_w-qrS1zy1az7j6uiBOo4XrH9JhZqmf4Ksl0HNKASE_mp7eCDZx5az9iJgZXBfXoemy5hyphenhyphenlCTNLOCxwiYuKjIuJXGRiXw/s1600-h/NotifyControl1.PNG"><img style="cursor: pointer; width: 320px; height: 252px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSuGnj7aIp0vT9LdFpHZiYJ2Dz_hTFOuAWc9EZOcYq7bBvG6_w-qrS1zy1az7j6uiBOo4XrH9JhZqmf4Ksl0HNKASE_mp7eCDZx5az9iJgZXBfXoemy5hyphenhyphenlCTNLOCxwiYuKjIuJXGRiXw/s320/NotifyControl1.PNG" alt="" id="BLOGGER_PHOTO_ID_5397939955886342642" border="0" /></a><br /><br />2. Change NotifyIcon properties.<br /><div style="text-align: left;"> <blockquote>BalloonTipIcon = Info<br /> BalloonTipText = Running<br /> Change Icon<br /> Text = Running Your Program<br /> Visible = True</blockquote><br /></div><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgQSTWFMZ5G0AQcXTwqDalKwwIyE_lZlEPGzGWe5Q3J6Z4FO3GbxuKfIzanqM4pcK9pEanEG5rLdvkzPc73tVuvC4rxgeKb7fVLJvNwDvHEH7jETe3Mo4wfkU2wc5MbHKHEvd2Iwwig3A/s1600-h/Property.PNG"><img style="cursor: pointer; width: 320px; height: 223px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgQSTWFMZ5G0AQcXTwqDalKwwIyE_lZlEPGzGWe5Q3J6Z4FO3GbxuKfIzanqM4pcK9pEanEG5rLdvkzPc73tVuvC4rxgeKb7fVLJvNwDvHEH7jETe3Mo4wfkU2wc5MbHKHEvd2Iwwig3A/s320/Property.PNG" alt="" id="BLOGGER_PHOTO_ID_5397941319543501506" border="0" /></a><br /><br />3. Add code in Event Form1_Resize.<p><span style="color: rgb(0, 0, 102);"></span><span style="color: rgb(0, 0, 102);font-size:85%;" ></span></p><blockquote><span style="color: rgb(0, 0, 102);font-size:85%;" >Private Sub Form1_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) _</span><span style="font-size:85%;"><br /></span><span style="color: rgb(0, 0, 102);font-size:85%;" > Handles MyBase.Resize</span><span style="font-size:85%;"><br /></span><span style="color: rgb(0, 0, 102);font-size:85%;" ><span style="color: rgb(51, 204, 0);">' If minimize form that will show in system tray</span>.</span><span style="font-size:85%;"><br /></span><span style="color: rgb(0, 0, 102);font-size:85%;" >If System.Windows.Forms.FormWindowState.Minimized = WindowState Then</span><span style="font-size:85%;"><br /></span><span style="color: rgb(0, 0, 102);font-size:85%;" > sysMonTray.ShowBalloonTip(5, "Running", "Running Your Program", ToolTipIcon.Info)</span><span style="font-size:85%;"><br /></span><span style="color: rgb(0, 0, 102);font-size:85%;" >Me.Hide() </span><span style="font-size:85%;"><br /></span><span style="color: rgb(0, 0, 102);font-size:85%;" > End If</span><span style="font-size:85%;"><br /></span><span style="color: rgb(0, 0, 102);font-size:85%;" > End Sub</span></blockquote><span style="color: rgb(0, 0, 102);font-size:85%;" ></span><blockquote></blockquote><span style="color: rgb(0, 0, 102);"></span><p></p><p><br /></p><p><span style="color: rgb(0, 0, 0);">4. Add code in Event NotifyIcon_Click to hide an</span><span style="color: rgb(0, 0, 102);"><span style="color: rgb(0, 0, 0);">d show form.</span><br /></span></p><p><span style="color: rgb(0, 0, 102);"> </span></p><blockquote style="font-family:arial;"><span style="color: rgb(0, 0, 102);font-size:85%;" >Private Sub sysMonTray_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _<br /> Handles sysMonTray.Click<br /></span><span style="font-size:85%;"><br /></span><span style="color: rgb(0, 0, 102);font-size:85%;" > If Me.Visible Then<br /> Me.Hide()<br /> Else<br /> Me.Show()<br /> Me.ShowInTaskbar = True<br /> Me.WindowState = FormWindowState.Normal<br /> Me.StartPosition = FormStartPosition.CenterScreen<br /> End If<br /><br /> End Sub</span></blockquote><span style="color: rgb(0, 0, 102);"></span><p></p><p><span style="color: rgb(0, 0, 102);"><br /></span></p><p style="text-align: center;"><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidZKGJcozK4byiHlHP-cD-vtB5ZyK3Z7acgMuJRGoiLkgqAuu4y94OAeIvigmCmFSdhBjfUZwmnif054JFO-g2El9XUEQfiSP4_tXGryNjmQqbd-60Fw619vgsISszaAPX4m5i6IfCHJ8/s1600-h/SystemTray.PNG"><img style="cursor: pointer; width: 148px; height: 93px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidZKGJcozK4byiHlHP-cD-vtB5ZyK3Z7acgMuJRGoiLkgqAuu4y94OAeIvigmCmFSdhBjfUZwmnif054JFO-g2El9XUEQfiSP4_tXGryNjmQqbd-60Fw619vgsISszaAPX4m5i6IfCHJ8/s320/SystemTray.PNG" alt="" id="BLOGGER_PHOTO_ID_5397948738163281746" border="0" /></a></p>Unknownnoreply@blogger.com20tag:blogger.com,1999:blog-6215844475637970091.post-29184580314966059472008-06-08T20:44:00.000-07:002008-06-08T20:53:32.751-07:00Make your programs run on Windows startupThe two best methods for automatically launching a program at startup are to use the registry or the system's Startup folder. Which method you choose depends on how easy you want to make it for the user to remove the program if he or she decides that it shouldn't run at system startup. Using the Startup folder gives the user more control; to prevent the program from running at startup, the user just has to remove its shortcut from the folder. Using the registry makes it less accessible; the user will have to be familiar with the structure of the registry and will have to know how to use an editing tool like RegEdit in order to prevent the application from running at startup. <br />Sample Code.<br /><br /><span style="color:#000099;">'Write to register</span><br /><span style="color:#000099;">Dim regKey As Microsoft.Win32.RegistryKeyregKey </span><br /><span style="color:#000099;">regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True)</span><br /><span style="color:#000099;">regKey.SetValue("YourApplicationName", "YourInstallPath")</span><br /><span style="color:#000099;">regKey.Close()</span><br /><br /><br />If you want to remove from register use this code.<br /><br /><span style="color:#000099;">regKey.DeleteValue("YourApplicationName", False)</span>Unknownnoreply@blogger.com102tag:blogger.com,1999:blog-6215844475637970091.post-68128188257617794912008-06-03T03:33:00.000-07:002008-06-03T04:04:45.858-07:00Insert picture into Report<span style="font-weight: bold;">Insert picture into report by convert picture to byte array and add to report.</span><br /><br /><br />1. Add picture column in ReportDataset.xsd and set data type to System.Byte() then compile project.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhY7BCeyYC1Oq4UtpnvUElaiJk4Pcl_QCeJt6Ow0HrDhZWIWsOQAS6GN9Nt4B1SmDmTUB0lh6Wf6TPxKZes78VzBqgGnf-tr-aWolveMHHLnfW7wfXVCxJqQfFn1a8XotJ6oBuF65SedxM/s1600-h/cry1.PNG"><img style="cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhY7BCeyYC1Oq4UtpnvUElaiJk4Pcl_QCeJt6Ow0HrDhZWIWsOQAS6GN9Nt4B1SmDmTUB0lh6Wf6TPxKZes78VzBqgGnf-tr-aWolveMHHLnfW7wfXVCxJqQfFn1a8XotJ6oBuF65SedxM/s320/cry1.PNG" alt="" id="BLOGGER_PHOTO_ID_5207602028525172162" border="0" /></a><br /><br /><br />2. Open CustomerReport.rpt , right click Database Fields and select Verify Database menu. Insert Picture column into report.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhK3XSGYDxeJNQqp1XY5KBUD1YQf0237cSWYZmvDO_ixhYH-fE2ejj4u7K_snT0sZr0ZSx4cIzycse2OLU6_8vjdCuNtNcrZe5V_trdON_1p8RGYptVJvyuY11PqMhCMZp_q520BCHa94w/s1600-h/cry2.PNG"><img style="cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhK3XSGYDxeJNQqp1XY5KBUD1YQf0237cSWYZmvDO_ixhYH-fE2ejj4u7K_snT0sZr0ZSx4cIzycse2OLU6_8vjdCuNtNcrZe5V_trdON_1p8RGYptVJvyuY11PqMhCMZp_q520BCHa94w/s320/cry2.PNG" alt="" id="BLOGGER_PHOTO_ID_5207602040780163250" border="0" /></a><br /><br /><br />3. At CreateDataSet function insert this code for add new picture data column.<br /><br /><span style="color: rgb(204, 0, 0);"> dt.Columns.Add("Picture", Type.GetType("System.Byte[]"))</span><br /><br />4. Create new function.<br /><br /><span style="color: rgb(0, 0, 153);"> Private Function CreatePictureArray(ByVal bImagePath As String) As Byte()</span> <span style="color: rgb(0, 0, 153);"><br /> Dim imgLogo As System.Drawing.Image = System.Drawing.Image.FromFile(bImagePath)</span> <span style="color: rgb(0, 0, 153);"><br /> Dim msLogo As New IO.MemoryStream()</span> <span style="color: rgb(0, 0, 153);"> imgLogo.Save(msLogo, <br /> System.Drawing.Imaging.ImageFormat.Bmp)</span> <br /> <br /> <span style="color: rgb(0, 0, 153);">Return msLogo.ToArray()</span> <span style="color: rgb(0, 0, 153);"><br /> End Function<br /><br /><span style="color: rgb(0, 0, 0);">5. Convert image to byte array and bind to datarow.<br /></span></span><br /><span style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 0);"><span style="color: rgb(0, 0, 153);"> ' Create new row</span> <span style="color: rgb(0, 0, 153);"><br /> Dim dr As DataRow = ds.Tables(0).NewRow</span> <span style="color: rgb(0, 0, 153);"><br /> dr("Title") = "Mr"</span><br /><span style="color: rgb(0, 0, 153);"> dr("FirstName") = "Tom"</span> <span style="color: rgb(0, 0, 153);"><br /> dr("LastName") = "Brown"</span> <span style="color: rgb(0, 0, 153);"><br /> dr("Address") = "Tom Address"</span><br /><span style="color: rgb(0, 0, 153);"><span style="color: rgb(255, 0, 0);"> dr("Picture") = CreatePictureArray("c:\person.jpg")</span><br /><br /><span style="color: rgb(0, 0, 0);">6. Show Report<br /></span></span></span></span><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqbgFWnGLt7JAtMfmWSCOmYX7SKQjV1QKNJ10jx_k317I5USUHtvWuP6OK0yWR95nQocZ-x_iR8Brs0H72EAC9MGL5XUivyIgLgoIIYBz0aRY5BlhHi87P7X6abQ_REni74EMHJRRI9jM/s1600-h/cry3.PNG"><img style="cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqbgFWnGLt7JAtMfmWSCOmYX7SKQjV1QKNJ10jx_k317I5USUHtvWuP6OK0yWR95nQocZ-x_iR8Brs0H72EAC9MGL5XUivyIgLgoIIYBz0aRY5BlhHi87P7X6abQ_REni74EMHJRRI9jM/s320/cry3.PNG" alt="" id="BLOGGER_PHOTO_ID_5207608025591565138" border="0" /></a>Unknownnoreply@blogger.com18tag:blogger.com,1999:blog-6215844475637970091.post-11148334264621284412008-05-10T21:31:00.000-07:002008-05-11T05:32:52.621-07:00Create Report<strong>Create report by vb.net and crystal report</strong><br /><br />1. Create new visual basic project.<img id="BLOGGER_PHOTO_ID_5199088978421647506" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: left" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieROdUO12GZEh54Ax7s2BLxxOy6S576ZG2rPKiSZAQ_sMx1rbUHKJYFTdmNw5hExzQnrl_mJmzn-k0gWWYRualPR-zQnTVmKngPkgIFZbQRdFhSlmh6MixL3j-FgNlnvFzYqg8vJ2Zhi4/s320/01.PNG" border="0" /><br /><br /><p>2. Add button and CrystalReportViewer to form1. <a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEim5MjHk-S_uy3__pt1Knjo5BOKMEHKfhz8kgGw6arhfqNXvNtdlhvwt0r7lbTbORQ8sZr71Fq4FZ1Voge7o6lkaqCvC8ZMb53yTOAMgs3NZe21JRp5TPD4yxxAYjFynJKvSHjLqs_6anQ/s1600-h/02.PNG"><img id="BLOGGER_PHOTO_ID_5199089734335891618" style="FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEim5MjHk-S_uy3__pt1Knjo5BOKMEHKfhz8kgGw6arhfqNXvNtdlhvwt0r7lbTbORQ8sZr71Fq4FZ1Voge7o6lkaqCvC8ZMb53yTOAMgs3NZe21JRp5TPD4yxxAYjFynJKvSHjLqs_6anQ/s320/02.PNG" border="0" /></a><br /><br /><br /><br /><br /><br /><br /></p><br /><p><br /></p><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />3. Add new DataSet item.<br /><img id="BLOGGER_PHOTO_ID_5199090185307457714" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: left" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5XcnafWXaNgSgAAe793Z8HCd8rrQ19cyB_6zov2lfrNBOoHPpCF0tP3R-4l7vkBFlb8GRM5gD0c5ou88x0deCLt-jVm3rTAQhwoaoXMxg12V24yxw441m-_F1sSbJyBUbLp4hjbsswpc/s320/03.PNG" border="0" /><br />4. Add DataTable in dataset design page and add data table columns.<br />- Title, FirstName, LastName, Address<br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBhXQ2i4WHCXbh18HWdPTtMKI2f9QSPC_9-8tIDEqeNjGxKp1Jl6owuItwfPbJRZc7_okByNuY37CKTXO6hWFY_MjQc8bF2tDs41MvgCjiFvFGpCWXRLBVWPBEsEHenqGPrCN5VQ8IWgY/s1600-h/04.PNG"><img id="BLOGGER_PHOTO_ID_5199090936926734530" style="FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBhXQ2i4WHCXbh18HWdPTtMKI2f9QSPC_9-8tIDEqeNjGxKp1Jl6owuItwfPbJRZc7_okByNuY37CKTXO6hWFY_MjQc8bF2tDs41MvgCjiFvFGpCWXRLBVWPBEsEHenqGPrCN5VQ8IWgY/s320/04.PNG" border="0" /></a><br /><br /><br /><br /><br /><br /><br /><br /><p></p><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtqYqyOOCD73GEzKL7ivku0W673BGxtfQ4xOkiZiGI08Q0e_MfWg7BBnprJ_40xnQImEH_etzUAImLiY1euzSoVVb1XLsLJzLv9Je5VGC08U7dPLaH8Pb_EUAE4rju4ejxfSRBzpT37zE/s1600-h/05.PNG"><img id="BLOGGER_PHOTO_ID_5199091929064179922" style="FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtqYqyOOCD73GEzKL7ivku0W673BGxtfQ4xOkiZiGI08Q0e_MfWg7BBnprJ_40xnQImEH_etzUAImLiY1euzSoVVb1XLsLJzLv9Je5VGC08U7dPLaH8Pb_EUAE4rju4ejxfSRBzpT37zE/s320/05.PNG" border="0" /></a><br /><br /><br /><br /><br /><br /><br /><br /><p> </p><p><br /> </p><p></p><p></p>5. Add Crystal Report item by select report document as a blank report<br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNgod0SLgNvb3FhwNmuHcPoKZjthJ2zoWC3hnPqgVppAjwrogJD7a_WRBJNbVjQlellu-6GWaPjaA1qY-GAR3SViE41CG5hyphenhyphenqwFTro8lXLkB0RjCAHid864eBwA8CFt7AhkluvVosqF9w/s1600-h/06.PNG"><img id="BLOGGER_PHOTO_ID_5199092951266396386" style="FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNgod0SLgNvb3FhwNmuHcPoKZjthJ2zoWC3hnPqgVppAjwrogJD7a_WRBJNbVjQlellu-6GWaPjaA1qY-GAR3SViE41CG5hyphenhyphenqwFTro8lXLkB0RjCAHid864eBwA8CFt7AhkluvVosqF9w/s320/06.PNG" border="0" /></a><br /><br /><br /><br /><br /><br /><p><br /><br /></p><br /><br /><br /><br /><br /><br /><p></p><p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgC32-sTe0i7gZMolxkM_7b11SQRSgyYjb4Lh5sHcKhXhWf2TZ7bGhiBAK-E764Ht4G0WqIWOtqTAk_VmuVLhXRpg5xqKVMvWNTBYHMm-b5DSYkXt0GdATG9hckE-pyEXuKMG-D0j5yZzw/s1600-h/07.PNG"><img id="BLOGGER_PHOTO_ID_5199093668525934834" style="FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgC32-sTe0i7gZMolxkM_7b11SQRSgyYjb4Lh5sHcKhXhWf2TZ7bGhiBAK-E764Ht4G0WqIWOtqTAk_VmuVLhXRpg5xqKVMvWNTBYHMm-b5DSYkXt0GdATG9hckE-pyEXuKMG-D0j5yZzw/s320/07.PNG" border="0" /></a></p><br /><br /><br /><br /><br /><p></p><br /><br /><br /><br /><br /><p></p><br /><br /><br /><br /><br /><p></p><br /><br /><br /><br /><br /><br /><br /><p></p><p> </p><p>6. On Field Explorer right click at Database Fields and select Database Expert. </p>7. Select Project Data -> ADO.NET DataSets and add customer table to ReportDataset.<br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj77CM3SmHbVwQk8EBRKwYt2e2QiWIAeKW3kYOTSgmk38ZaFjgJ-vX4ORAhk8tDYyO1pQ3arXp4HDwL6bx4klS3ZcWRQ2skE_vhGvoWplC2FKFSm-ERrmsPfJPNHnk0ZV06iM1KxgNfCDA/s1600-h/08.PNG"><img id="BLOGGER_PHOTO_ID_5199094252641487106" style="FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj77CM3SmHbVwQk8EBRKwYt2e2QiWIAeKW3kYOTSgmk38ZaFjgJ-vX4ORAhk8tDYyO1pQ3arXp4HDwL6bx4klS3ZcWRQ2skE_vhGvoWplC2FKFSm-ERrmsPfJPNHnk0ZV06iM1KxgNfCDA/s320/08.PNG" border="0" /></a><br /><br /><br /><br /><br /><p></p><br /><br /><br /><br /><p></p><br /><br /><br /><br /><p></p><br /><br /><br /><br /><p></p><br /><br /><br /><p></p><p>8. Design Report (Add report header name txtHeader and report footer name txtFooter).<br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4ZsoksjmGRh37Ct2HYLWt45zNqKuvaX8GvxuwNNWuxLzx3GljkssWdSOSCxXhVDboPVrqRrWIlRjli-g6_FpX-byji0yd_OcY4MkSeCYtZsi6T969KZBzAKn7-wtU7dRodS269GihFFU/s1600-h/09.PNG"><img id="BLOGGER_PHOTO_ID_5199095352153114898" style="FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4ZsoksjmGRh37Ct2HYLWt45zNqKuvaX8GvxuwNNWuxLzx3GljkssWdSOSCxXhVDboPVrqRrWIlRjli-g6_FpX-byji0yd_OcY4MkSeCYtZsi6T969KZBzAKn7-wtU7dRodS269GihFFU/s320/09.PNG" border="0" /></a><br /></p><br /><p></p><br /><br /><br /><p></p><p><br /> </p><p>9. Sample code to show report.<br /><span style="font-size:78%;"><br /><span style="color:#000099;">Private Sub btnShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShow.Click<br /><span style="color:#009900;">' Get data to dataset</span><br />Dim CustomerData As DataSet = CreateDataSet()<br /><br /><span style="color:#009900;">' Create report instance and set data to report data source</span><br />Dim rpt As New CustomerReport<br />rpt.SetDataSource(CustomerData.Tables(0))<br /><br /><span style="color:#009900;">' Access crystal report object<br />' Sample to access textbox object </span><br />Dim txtHeader As CrystalDecisions.CrystalReports.Engine.TextObject = rpt.Section2.ReportObjects("txtHeader")<br />txtHeader.Text = "This is Report Header"<br /><br />Dim txtFooter As CrystalDecisions.CrystalReports.Engine.TextObject = rpt.Section2.ReportObjects("txtFooter")<br />txtFooter.Text = "This is Report Footer"<br /><br /><span style="color:#009900;">' Show Report</span><br />Me.CrystalReportViewer1.ReportSource = rpt<br /><br />End Sub<br /><br />Private Function CreateDataSet() As DataSet<br />Dim ds As New DataSet("ReportDataset")<br /><br /><span style="color:#009900;">' Create Table</span><br />Dim dt As New DataTable("Customer")<br />dt.Columns.Add("Title", Type.GetType("System.String"))<br />dt.Columns.Add("FirstName", Type.GetType("System.String"))<br />dt.Columns.Add("LastName", Type.GetType("System.String"))<br />dt.Columns.Add("Address", Type.GetType("System.String"))<br /><br /><span style="color:#009900;">' Add DataTable to DataSet</span><br />ds.Tables.Add(dt)<br /><br /><span style="color:#009900;">' Create new row</span><br />Dim dr As DataRow = ds.Tables(0).NewRow<br />dr("Title") = "Mr"<br />dr("FirstName") = "Tom"<br />dr("LastName") = "Brown"<br />dr("Address") = "Tom Address"<br />ds.Tables(0).Rows.Add(dr)<br /><br />dr = ds.Tables(0).NewRow<br />dr("Title") = "Mr"<br />dr("FirstName") = "John"<br />dr("LastName") = "Grary"<br />dr("Address") = "John Address"<br />ds.Tables(0).Rows.Add(dr)<br /><br />dr = ds.Tables(0).NewRow<br />dr("Title") = "Mr"<br />dr("FirstName") = "Alex"<br />dr("LastName") = "Smith"<br />dr("Address") = "Alex Address"<br />ds.Tables(0).Rows.Add(dr)<br /><br />Return ds<br />End Function<br /></span></span><br /><br />10. Show Report.<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiID5Rj14sR0KJhZlZ8w5lbggbqqRUSjspy9qoRFFlUHXRyiC6-1Od7_40xyZ_M6Xnr_I1CBNM40YB3I5eQu_rfskkyZxDQfO8bwJrA1-PciUqzjtzQLFwujQYE8zRtbUfDb6enjEtdsBQ/s1600-h/10.PNG"><img id="BLOGGER_PHOTO_ID_5199095880434092322" style="FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiID5Rj14sR0KJhZlZ8w5lbggbqqRUSjspy9qoRFFlUHXRyiC6-1Od7_40xyZ_M6Xnr_I1CBNM40YB3I5eQu_rfskkyZxDQfO8bwJrA1-PciUqzjtzQLFwujQYE8zRtbUfDb6enjEtdsBQ/s320/10.PNG" border="0" /></a><br /></p><br /><br /><br /><p></p>Unknownnoreply@blogger.com8tag:blogger.com,1999:blog-6215844475637970091.post-31034855981278916542008-05-05T23:15:00.000-07:002008-05-05T23:34:53.922-07:00BackgroundWorker<p><strong>BackgroundWorker Class</strong></p><p>Executes an operation on a separate thread.</p><p>Sample Code</p><p>1.Create event DoWork.</p><p><span style="color:#000099;">Private Sub BackgroundWorker1_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs)<br /></span><span style="color:#000099;">'Sample how to disable button send before send email method after that enabled button.</span><span style="color:#000099;"><br />DisableSendButton()<br />' to do SendEmail method<br />EnabledSendButton()</span><span style="color:#000099;"><br /></span><span style="color:#000099;">End Sub</span></p><p><span style="color:#000000;">2. Show how to invoke method when use BackgroundWorker control.</span></p><p><span style="color:#000099;">Private Sub DisableSendButton()<br />If Me.InvokeRequired Then<br />Me.Invoke(New MethodInvoker(DisableSendButton))<br />Else<br />btnSend.Enabled = False<br />btnCancelSend.Visible = True<br />End If<br />End Sub </span></p><p><span style="color:#000099;">Private Sub EnabledSendButton()<br />If Me.InvokeRequired Then<br />Me.Invoke(New MethodInvoker(EnabledSendButton))<br /></span><span style="color:#000099;">Else<br />btnSend.Enabled = True<br />btnCancelSend.Visible = False<br />End If<br />End Sub </span></p><p><span style="color:#000099;"></span></p><p>3.Start BackgroundWorker</p><p><span style="color:#000099;">BackgroundWorker1.RunWorkerAsync()</span></p>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-6215844475637970091.post-77391946490685295092008-03-01T00:25:00.000-08:002008-03-13T14:05:04.837-07:00CheckedListBox<span style="FONT-WEIGHT: bold">Sample Code</span><br /><strong></strong><br /><span style="FONT-WEIGHT: bold">Add Object to CheckedListBox</span><br /><br /><span style="COLOR: rgb(0,0,153)">Dim pItem As CarItem</span><br /><br /><span style="COLOR: rgb(0,0,153)">pItem = New CarItem() </span><br /><span style="COLOR: rgb(0,0,153)">pItem.CarId = 1</span><br /><span style="COLOR: rgb(0,0,153)">pItem.CarName="CarName"</span><br /><br /><span style="COLOR: rgb(0,0,153)">' Add this object to CheckListBox</span><br /><span style="COLOR: rgb(0,0,153)">' And CheckListBox show CarName because I override toString function</span><br /><span style="COLOR: rgb(0,0,153)">Me.CheckListBox1.Items.Add(pItem, True) </span><br /><br /><span style="COLOR: rgb(0,0,153)">' Class CarItem</span><br /><br /><span style="COLOR: rgb(0,0,153)">Private Class CarItem</span><br /><br /><span style="COLOR: rgb(0,0,153)">Public CarId As Integer </span><br /><span style="COLOR: rgb(0,0,153)">Public CarName As String</span><br /><br /><span style="COLOR: rgb(0,0,153)">Public Sub New()</span><br /><br /><span style="COLOR: rgb(0,0,153)">End Sub </span><br /><br /><span style="COLOR: rgb(0,0,153)">' Override tostring</span><br /><span style="COLOR: rgb(0,0,153)">Public Overrides Function ToString() As String</span><br /><span style="COLOR: rgb(0,0,153)">Return CarName</span><br /><span style="COLOR: rgb(0,0,153)">End Function</span><br /><br /><span style="COLOR: rgb(0,0,153)">End Class</span><br /><span style="color:#000099;"></span><br /><span style="color:#000099;"></span><br /><span style="color:#000099;"></span><br /><strong>Get status items in CheckedListBox</strong><br /><br /><span style="color:#000099;">For i As Integer = 0 To Me.CheckedListBox.Items.Count - 1<br /> If Me.CheckedListBox.GetItemChecked(i) Then<br /> 'TODO Something </span><br /><span style="color:#000099;"> End If </span><br /><span style="color:#000099;">Next i</span><br /><br /><strong>Get only Checked Items</strong><br /><br /><span style="color:#000099;">For i As Integer = 0 To Me.CheckedListBox.CheckedItems.Count - 1<br /> 'TODO Something<br />Next</span><br /><br /><br /><strong>Set all item checked</strong><br /><br /><span style="color:#000099;">For i As Integer = 0 To Me.CheckedListBox.Items.Count-1<br /> Me.CheckedListBox.SetItemChecked(i, true) </span><br /><span style="color:#000099;">Next i</span>Unknownnoreply@blogger.com7tag:blogger.com,1999:blog-6215844475637970091.post-72051313905014354252008-02-23T01:09:00.000-08:002008-02-23T01:41:12.026-08:00Windows Controls<span style="font-weight: bold;">Controls </span><br /><br />A control is an object that can be drawn on to the Form to enable or enhance user interaction with the application. Examples of these controls, TextBoxes, Buttons, Labels, Radio Buttons, etc. All these Windows Controls are based on the Control class, the base class for all controls. Visual Basic allows us to work with controls in two ways: at design time and at runtime. Working with controls at design time means, controls are visible to us and we can work with them by dragging and dropping them from the Toolbox and setting their properties in the properties window. Working at runtime means, controls are not visible while designing, are created and assigned properties in code and are visible only when the application is executed. There are many new controls added in Visual Basic .NET and we will be working with some of the most popular controls in this section. You can select the controls from the menu towards the left-hand side of this page.<br /><br />Notable properties of most of these Windows Controls which are based on the Control class itself are summarized in the table below. You can always find the properties of the control with which you are working by pressing F4 on the keyboard or by selecting View->Properties Window from the main menu.<br /><br /><span style="font-weight: bold;">The Control Class </span><br /><br />The Control class is in the System.Windows.Forms namespace. It is a base class for the Windows Controls. The class hierarchy is shown below.<br /><br />Object<br />MarshalByRefObject<br />Component<br />Control<br /> ButtonBase, Etc, Etc<br /> Button, Etc, Etc<br /><br />Main class is the Object class from which MarshalByRefObject class is derived and the Component class is derived from the MarshalByRefObject class and so on.<br /><br />The properties of the Control object are summarized below. Properties are alphabetical as seen in the properties window.<br /><br /><br /><table id="Table1" title="Control Object Properties" bg="" align="justify" border="1" cellpadding="4" cellspacing="4" rules="all" width="80%" style="color:Black;"><tbody><tr><td style="font-weight: bold; color: rgb(0, 0, 0);" bg="" valign="middle" width="30%"><span style=";font-family:Verdana;font-size:85%;" >Property</span></td><td style="color: rgb(0, 0, 0); font-weight: bold;" bg="" valign="middle" width="70%"><span style=";font-family:Verdana;font-size:85%;" >Description</span></td> </tr><tr> <td><span style=";font-family:Verdana;font-size:78%;color:Black;" >AllowDrop</span></td><td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Indicates if the form can accept data that the user drags and drops into it</span></td> </tr><tr> <td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Anchor</span></td><td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Gets/Sets which edges of the control are anchored</span></td> </tr><tr> <td><span style=";font-family:Verdana;font-size:78%;color:Black;" >BackColor</span></td><td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Gets/Sets the background color for the control</span></td> </tr><tr> <td><span style=";font-family:Verdana;font-size:78%;color:Black;" >BackgroundImage</span></td><td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Gets/Sets the <a id="KonaLink5" target="_new" class="kLink" style="text-decoration: underline ! important; position: static;" href="http://www.startvbdotnet.com/controls/default.aspx#"><span style="color: rgb(0, 153, 0) ! important; font-weight: 400; position: static;font-family:Verdana;font-size:10;" ><span class="kLink" style="border-bottom: 1px solid rgb(0, 153, 0); color: rgb(0, 153, 0) ! important; font-weight: 400; position: static; padding-bottom: 1px;font-family:Verdana;font-size:10;" ></span></span></a> background image in the control</span></td> </tr><tr> <td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Bottom</span></td><td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Gets the distance bewteen the bottom of the control and the top of its container client area</span></td> </tr><tr> <td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Bounds</span></td><td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Gets/Sets the controls bounding rectangle</span></td> </tr><tr> <td><span style=";font-family:Verdana;font-size:78%;color:Black;" >CanFocus</span></td><td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Returns a value specifying if the control can recieve focus</span></td> </tr><tr> <td><span style=";font-family:Verdana;font-size:78%;color:Black;" >CanSelect</span></td><td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Returns a value specifying if the control can be selected</span></td> </tr><tr> <td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Capture</span></td><td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Gets/Sets a value specifying if the control has captured the mouse</span></td> </tr><tr> <td><span style=";font-family:Verdana;font-size:78%;color:Black;" >CausesValidation</span></td><td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Gets/Sets a value specfying if the control causes validation for all controls that require validation</span></td> </tr><tr> <td><span style=";font-family:Verdana;font-size:78%;color:Black;" >ContainsFocus</span></td><td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Returns a value specifying if the control has the input focus</span></td> </tr><tr> <td><span style=";font-family:Verdana;font-size:78%;color:Black;" >ContextMenu</span></td><td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Gets/Sets the shortcut menu for the control</span></td> </tr><tr> <td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Controls</span></td><td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Gets/Sets the collection of controls contained within the control</span></td> </tr><tr> <td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Cursor</span></td><td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Gets/Sets the cursor<span style="text-decoration: underline;"><span style="font-weight: bold;"></span></span> to be displayed when the user moves the mouse over the form</span></td> </tr><tr> <td><span style=";font-family:Verdana;font-size:78%;color:Black;" >DataBindings</span></td><td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Gets the data bindings for the control</span></td> </tr><tr> <td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Dock</span></td><td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Gets/Sets which edge of the parent a control is docked to</span></td> </tr><tr> <td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Enabled</span></td><td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Gets/Sets a value indicating if the control is enabled </span></td> </tr><tr> <td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Focused</span></td><td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Returns a value specifying if the control has input focus</span></td> </tr><tr> <td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Font</span></td><td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Gets/Sets the font for the control</span></td> </tr><tr> <td><span style=";font-family:Verdana;font-size:78%;color:Black;" >ForeColor</span></td><td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Gets/Sets the foreground color of the control</span></td> </tr><tr> <td><span style=";font-family:Verdana;font-size:78%;color:Black;" >HasChildren</span></td><td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Returns a value specifying if the control contains child controls</span></td> </tr><tr> <td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Height</span></td><td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Gets/Sets the height of the control</span></td> </tr><tr> <td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Left</span></td><td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Gets/Sets the x-coordinates of a control's left edge in pixels</span></td> </tr><tr> <td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Location</span></td><td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Gets/Sets the co-ordinates of the upper-left corner of the control</span></td> </tr><tr> <td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Name</span></td><td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Gets/Sets name for the control</span></td> </tr><tr> <td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Parent</span></td><td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Gets/Sets the control's parent container</span></td> </tr><tr> <td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Right</span></td><td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Returns the distance between the right edge of the control and the left edge of it's container</span></td> </tr><tr> <td><span style=";font-family:Verdana;font-size:78%;color:Black;" >RightToLeft</span></td><td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Gets/Sets the value indicating if the alignment of the control's elements is reversed to support right-to-left fonts</span></td> </tr><tr> <td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Size</span></td><td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Gets/Sets size of the control in pixels</span></td> </tr><tr> <td><span style=";font-family:Verdana;font-size:78%;color:Black;" >TabIndex</span></td><td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Gets/Sets the tab order of this control in its container</span></td> </tr><tr> <td><span style=";font-family:Verdana;font-size:78%;color:Black;" >TabStop</span></td><td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Gets/Sets a value specifying if the user can tab to this control with the tab key</span></td> </tr><tr> <td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Tag</span></td><td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Gets/Sets an object that contains data about the control</span></td> </tr><tr> <td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Text</span></td><td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Gets/Sets the text for this control</span></td> </tr><tr> <td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Top</span></td><td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Gets/Sets the top coordinates of the control</span></td> </tr><tr> <td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Visible</span></td><td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Gets/Sets a value specifying if the control is visible</span></td> </tr><tr> <td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Width</span></td><td><span style=";font-family:Verdana;font-size:78%;color:Black;" >Gets/Sets the width of the control</span></td></tr></tbody></table><br /><br /><span style="font-weight: bold;">Control Tab Order<br /><br /></span>To move focus from one control to other quickly using the keyboard we can use the Tab key. We can set the order in which the focus is transferred by setting the tab order. The tab order is the order in which controls on the form receive the focus and is specified by the TabIndex property. To change the order in which a control receives focus we need to set the TabIndex property to different value for each control on the form. Lower values receive the focus first and proceed numerically through higher values. If there is a tie between TabIndex values, the focus first goes to the control that is closest to the front of the form.<br />We can also set the tab order graphically with Visual Studio by selecting Tab Index from the View menu. Boxes containing current tab order appear in each control when you select Tab Index from View menu. Click each control to set the correct tab order in which you want the controls to receive focus.<br /><br /><div> </div>Ref: www.startvbdotnet.com<br /><div> </div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6215844475637970091.post-83616000852098804272008-01-15T02:26:00.000-08:002008-01-15T02:29:26.797-08:00Check Database MemoryWhen I use the TaskPad in Enterprise Manager to check a database's allocated, used, and free space (as reported on the General tab), the values I see don't match the values I get when I use the sp_HelpDB and sp_Spaceused stored procedures. For example, when I checked one of my databases today, I got the following information:<br /><br /><ul><li>In TaskPad, Enterprise Manager reported that the database had 211549.75MB of allocated space, 110294.44MB of used space, and 101255.31MB of free space.</li></ul><ul><li>For the same database, the sp_Spaceused stored procedure told me I had 212113.50MB of allocated space and 19541.14MB of unallocated space.</li></ul><ul><li>The sp_helpDB stored procedure reported that I had an MDF file size of 211549.75MB.</li></ul><br />Can I use T-SQL to return the same information that I see when I use the TaskPad?<br /><br />To generate the information on the TaskPad, Enterprise Manager uses a combination of the following four queries.<br /><br /><span style="font-weight: bold; color: rgb(0, 0, 153);">EXEC sp_spaceused </span><br /><span style="font-weight: bold; color: rgb(0, 0, 153);">SELECT fileid, name, filename, size, growth, status, maxsize </span><br /><span style="font-weight: bold; color: rgb(0, 0, 153);">FROM dbo.sysfiles WHERE (status & 0x40) <>0 </span><br /><span style="font-weight: bold; color: rgb(0, 0, 153);">DBCC sqlperf(logspace) </span><br /><span style="font-weight: bold; color: rgb(0, 0, 153);">DBCC showfilestats </span><br /><br />Enterprise Manager uses SQL-DMO to retrieve the information. . . .<br /><br />Content by Microsoft's SQL Server Development Team Ask MicrosoftUnknownnoreply@blogger.com0tag:blogger.com,1999:blog-6215844475637970091.post-25949454709598192452008-01-06T03:20:00.000-08:002008-01-11T06:19:16.051-08:00Share EBook<span style="font-weight: bold;">Click and download E-Book</span><br /><br /><a href="http://w15.easy-share.com/10005161.html">1. <span id="fn10005161">ProgrammingVBDotNet</span></a><br /><a href="http://w15.easy-share.com/9334181.html">2. Wrox Beginning Database Design</a><br /><a href="http://w15.easy-share.com/9331781.html">3. Wrox Professional ASP.NET 2.0</a><br /><a href="http://w13.easy-share.com/14177501.html">4. SQL Server 2005</a><br /><a href="http://tinyurl.com/27vtp5">5. Crystal Report For VS2005</a>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6215844475637970091.post-50839025251200010892007-12-21T23:14:00.000-08:002008-01-11T22:28:49.762-08:00Internet Explorer 8Internet Explorer 8<br /><br />Just as he was the first to talk about IE7, Bill Gates kept the tradition alive and discussed IE8 at the Mix ‘n Mash event here on campus yesterday. Bill was talking to some bloggers about IE.Next and called it IE8, the same way we do here in the IE team hallway.<br /><br />So, yes, the version after IE7 is IE8. We looked at a lot of options for the product name. Among the names we considered and ruled out:<br /><br /> IE 7+1<br /> IE VIII<br /> IE 1000 (think binary)<br /> IE Eight!<br /> iIE<br /> IE for Web 2.0 (Service Pack 2)<br /> IE Desktop Online Web Browser Live Professional Ultimate Edition for the Internet (the marketing team really pushed for this one ;-)<br /> Ie2.079 (we might still use this for the Math Major Edition)<br /><br />Of course, some people care about other aspects of IE8 much more than they care about the name. As I’ve walked different people through the plan, I’ve gotten “Does it have feature X?” “When is the beta?” “When does it release” and even the more thoughtful “What are you trying to accomplish with this release?”<br /><br />You will hear a lot more from us soon on this blog and in other places. In the meantime, please don’t mistake silence for inaction.<br /><br />Thank you ieblog<br />Dean Hachamovitch<br />General Manager<br />Published Wednesday, December 05, 2007 2:33 PM by ieblogUnknownnoreply@blogger.com2tag:blogger.com,1999:blog-6215844475637970091.post-54166777051202946152007-12-13T23:45:00.000-08:002007-12-14T00:25:45.934-08:00Serialize & Deserialize Class To FileThis sample show serialize and deserialize by use binary format.<br /><br />1. Import this 2 names space<br /><br /><span style="color: rgb(0, 0, 153);">Imports System.Runtime.Serialization.Formatters.Binary</span><br /><span style="color: rgb(0, 0, 153);">Imports System.IO</span><br /><br />2. The class or object that you want implement must insert attribute Serializable.<br /><br /><code style="color: rgb(0, 0, 153);">< <span style="font-weight: bold;">system.serializable() </span>><br /></code><span style="color: rgb(0, 0, 153);">Public Class Person<br /></span><span style="color: rgb(0, 0, 153);">Private m_sFirstName As String<br /></span><span style="color: rgb(0, 0, 153);">Private m_sLastName As String<br /></span><br /><span style="color: rgb(0, 0, 153);">Public Sub New()</span><br /><span style="color: rgb(0, 0, 153);">End Sub<br /><br /></span><span style="color: rgb(0, 0, 153);">Public Property FirstName() As String<br /></span><span style="color: rgb(0, 0, 153);">Get<br /></span><span style="color: rgb(0, 0, 153);"> Return Me.m_sFirstName<br /></span><span style="color: rgb(0, 0, 153);">End Get<br /></span><span style="color: rgb(0, 0, 153);">Set(ByVal value As String)<br /></span><span style="color: rgb(0, 0, 153);"> Me.m_sFirstName = value<br /></span><span style="color: rgb(0, 0, 153);">End Set<br /></span><span style="color: rgb(0, 0, 153);">End Property<br /></span><br /><span style="color: rgb(0, 0, 153);">Public Property LastName() As String<br /></span><span style="color: rgb(0, 0, 153);">Get<br /></span><span style="color: rgb(0, 0, 153);"> Return Me.m_sLastName<br /></span><span style="color: rgb(0, 0, 153);">End Get<br /></span><span style="color: rgb(0, 0, 153);">Set(ByVal value As String)<br /></span><span style="color: rgb(0, 0, 153);"> Me.m_sLastName = value<br /></span><span style="color: rgb(0, 0, 153);">End Set<br /></span><span style="color: rgb(0, 0, 153);">End Property<br /></span><br /><span style="color: rgb(0, 0, 153);">Public ReadOnly Property FullName() As String<br /></span><span style="color: rgb(0, 0, 153);">Get<br /></span><span style="color: rgb(0, 0, 153);"> Return Me.m_sFirstName & " " & Me.m_sLastName<br /></span><span style="color: rgb(0, 0, 153);">End Get<br /></span><span style="color: rgb(0, 0, 153);">End Property<br /></span><br /><span style="color: rgb(0, 0, 153);">End Class</span><br /><br /><br />3. Sample code show how to do this.<br /><br /><span style="color: rgb(0, 153, 0);">' Create object instance</span><br /><span style="color: rgb(0, 0, 153);">Dim pPerson As New Person()</span><br /><br /><span style="color: rgb(0, 0, 153);">pPerson.FirstName = "TOM"</span><br /><span style="color: rgb(0, 0, 153);">pPerson.LastName = "BROWN"</span><br /><br /><span style="color: rgb(0, 153, 0);">' Create file by FileStream class</span><br /><span style="color: rgb(0, 0, 153);">Dim fs As FileStream = New FileStream("c:\test.bin", FileMode.OpenOrCreate)</span><br /><br /><span style="color: rgb(0, 153, 0);">' Creat binary object</span><br /><span style="color: rgb(0, 0, 153);">Dim bf As New BinaryFormatter()</span><br /><br /><span style="color: rgb(0, 153, 0);">' Serialize object to file</span><br /><span style="color: rgb(0, 0, 153);">bf.Serialize(fs, pPerson)</span><br /><span style="color: rgb(0, 0, 153);">fs.Close()</span><br /><br /><span style="color: rgb(0, 153, 0);">' Open file and deserialize to object again</span><br /><span style="color: rgb(0, 0, 153);">Dim fsRead As New FileStream("C:\test.bin", FileMode.Open)</span><br /><span style="color: rgb(0, 0, 153);">Dim objTest As Object = bf.Deserialize(fsRead)</span><br /><span style="color: rgb(0, 0, 153);">fsRead.Close()</span>Unknownnoreply@blogger.com4tag:blogger.com,1999:blog-6215844475637970091.post-78863223912372859022007-12-01T23:54:00.000-08:002007-12-13T23:07:45.750-08:00Caculate DateTime By TimeSpan ClassA TimeSpan object represents a time interval, or duration of time, measured as a positive or negative number of days, hours, minutes, seconds, and fractions of a second. The largest unit of time used to measure duration is a day. Time intervals are measured in days for consistency because the number of days in larger units of time, such as months and years, varies.<br /><br /><span style="font-weight: bold;">Sample Code</span><br /><br /><span style="color: rgb(0, 0, 153);">Dim dFirstDate As DateTime = DateTime.Now</span><br /><br /><span style="color: rgb(0, 153, 0);">' Add day</span><br /><span style="color: rgb(0, 0, 153);">Dim dLastDate As DateTime = DateTime.Now.AddDays(15)</span><br /><br /><span style="color: rgb(0, 153, 0);">' Subtract DateTime</span><br /><span style="color: rgb(0, 0, 153);">Dim pTimeSpan As TimeSpan = dLastDate.Subtract(dFirstDate)</span><br /><br /><span style="color: rgb(0, 153, 0);">' Subtract DateTime Output</span><br /><span style="color: rgb(0, 0, 153);">Console.WriteLine("Days : " & pTimeSpan.TotalDays)</span><br /><span style="color: rgb(0, 0, 153);">Console.WriteLine("Hours : " & pTimeSpan.TotalHours)</span><br /><span style="color: rgb(0, 0, 153);">Console.WriteLine("Minutes : " & pTimeSpan.TotalMinutes)</span><br /><span style="color: rgb(0, 0, 153);">Console.WriteLine("Seconds : " & pTimeSpan.TotalSeconds)<br /><br /><span style="color: rgb(0, 153, 0);">' Compare DateTime</span><br />Dim nResult As Integer = DateTime.Compare(dLastDate, dFirstDate)<br />If nResult = 0 Then<br /> Console.WriteLine("First date is equals to Last date")<br />ElseIf nResult > 0 Then<br /> Console.WriteLine("First date is lesser than the Last date")<br />Else<br /> Console.WriteLine("First date is greater than Last date")<br />End If<br /></span>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-6215844475637970091.post-3896467712882170982007-11-19T19:57:00.000-08:002008-03-25T22:09:17.601-07:00RegularExpressions ClassThe Regex class contains several static methods that allow you to use a regular expression without explicitly creating a Regex object. Using a static method is equivalent to constructing a Regex object, using it once and then destroying it.<br /><br /><span style="font-weight: bold;">Sample Code 1<br /><br /></span><span style="color: rgb(0, 0, 153);">Imports System.Text.RegularExpressions</span><br /><span style="color: rgb(0, 0, 153);">' import the namespace</span><br /><br /><span style="color: rgb(0, 0, 153);">'instantiate the objects</span><br /><span style="color: rgb(0, 0, 153);">dim oRegex as new regex("test pattern")</span><br /><br /><span style="color: rgb(0, 0, 153);">'use the object</span><br /><span style="color: rgb(0, 0, 153);">If oRegex.IsMatch("this is the string to test on") Then</span><br /><span style="color: rgb(0, 0, 153);"> msgbox "Match found"</span><br /><span style="color: rgb(0, 0, 153);">else</span><br /><span style="color: rgb(0, 0, 153);"> msgbox "Did not find match"</span><br /><span style="color: rgb(0, 0, 153);">end i</span><br /><br /><br /><span style="font-weight: bold;">Sample Code 2<br /><br /></span><span style="color: rgb(0, 0, 153);">//Check for correct format of your name</span><br /><br /><span style="color: rgb(0, 0, 153);">Dim myMatch As Match = System.Text.RegularExpressions.Regex.Match(InsertYourName, "^[A-Z][a-zA-Z]*$")</span><br /><br /><span style="color: rgb(0, 0, 153);"> If Not myMatch.Success Then</span><br /><br /><span style="color: rgb(0, 0, 153);"> 'Name was incorrect</span><br /><br /><span style="color: rgb(0, 0, 153);"> ErrorMessage("Invalid Name", "Message")</span><br /><br /><span style="color: rgb(0, 0, 153);"> txtFname.Focus()</span><br /><br /><span style="color: rgb(0, 0, 153);"> Return</span><br /><br /><span style="color: rgb(0, 0, 153);"> End If<br /><br /><br /><span style="color: rgb(0, 0, 0); font-weight: bold;">Regular Expressions Elements:</span><br /><br /><span style="color: rgb(0, 0, 0);"> * . Character except a newline character(\n)</span><br /><span style="color: rgb(0, 0, 0);"> * \d Any decimal digit</span><br /><span style="color: rgb(0, 0, 0);"> * \D Any nondigit</span><br /><span style="color: rgb(0, 0, 0);"> * \s Any white-space character</span><br /><span style="color: rgb(0, 0, 0);"> * \S Any Non-white-space charater</span><br /><span style="color: rgb(0, 0, 0);"> * \w Any word character</span><br /><span style="color: rgb(0, 0, 0);"> * \W Any nonword character</span><br /><span style="color: rgb(0, 0, 0);"> * ^ Beginning of string or line</span><br /><span style="color: rgb(0, 0, 0);"> * \A Beginning of string</span><br /><span style="color: rgb(0, 0, 0);"> * $ End of string or line</span><br /><span style="color: rgb(0, 0, 0);"> * \z End of string</span><br /><span style="color: rgb(0, 0, 0);"> * | Matches one of the expressions seprated by the vertical bar; example eee|ttt will match one of eee or ttt (tracing left to right)</span><br /><span style="color: rgb(0, 0, 0);"> * [abc] Match with one of the characters; example [rghy] will match r, g,h or c not any other character.</span><br /><span style="color: rgb(0, 0, 0);"> * [^abc] Match with any of character except in list; example [ghj] will match all character except g,h or k.</span><br /><span style="color: rgb(0, 0, 0);"> * [a-z] Match any character within specified range; example [a - c] will match a, b or c.</span><br /><span style="color: rgb(0, 0, 0);"> * ( ) Subexpression treated as a single element by regular expression elements described in this table.</span><br /><span style="color: rgb(0, 0, 0);"> * ? Match one or zero occurrences of the previous character or subexpression; example a?b will match a or ab not aab.</span><br /><span style="color: rgb(0, 0, 0);"> * * Match zero or more occurences of the previous character or subexpression; example a*b will match b, ab, aab and so on. </span><br /><span style="color: rgb(0, 0, 0);"> * + Match one or more occurences of the previous character or subexpression; example a+b will match ab, aab and so on but not b.</span><br /><span style="color: rgb(0, 0, 0);"> * {n} Match exactly n occurrences of the preceding character;example a{2} will match only aa.</span><br /><span style="color: rgb(0, 0, 0);"> * {n,} Match minimum</span> <span style="color: rgb(0, 0, 0);">n occurrences of the preceding character;example a{2,} will match only</span><span style="color: rgb(0, 0, 0);"> aa,aaa and so on.</span><br /><span style="color: rgb(0, 0, 0);"> * {n,m} Match minimum n and maximum n occurrences of the preceding character;example a{2, 4} will match aa, aaa, aaaa but not aaaaa.</span><br /></span>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-6215844475637970091.post-57970888965505148842007-11-15T19:56:00.000-08:002007-11-15T19:57:08.407-08:00Visual Studio 2008 Beta 2 Professional Edition<span style="font-weight: bold;">Product Information and Availability<br /><br /></span>Visual Studio 2008 and the .NET Framework 3.5 will be available by the end of November 2007. The .NET Framework 3.5 will also be available to end users via a free, optional download from Microsoft Update. A CTP of Microsoft Sync Framework is available today at http://msdn.microsoft.com/sync. Popfly Explorer is a hosted development environment available today at http://www.popfly.com. More information about all of these releases is available at http://www.msdn.microsoft.com/vstudio.<br />Founded in 1975, Microsoft (Nasdaq “MSFT”) is the worldwide leader in software, services and solutions that help people and businesses realize their full potential.<br />Note to editors: If you are interested in viewing additional information on Microsoft, please visit the Microsoft Web page at http://www.microsoft.com/presspass on Microsoft’s corporate information pages. Web links, telephone numbers and titles were correct at time of publication, but may since have changed. For additional assistance, journalists and analysts may contact Microsoft’s Rapid Response Team or other appropriate contacts listed at http://www.microsoft.com/presspass/contactpr.mspx.<br /><br />Download beta version at : <a href="http://msdn2.microsoft.com/en-us/evalcenter/bb655864.aspx">http://msdn2.microsoft.com/en-us/evalcenter/bb655864.aspx</a>Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-6215844475637970091.post-83109355712607300512007-11-08T23:31:00.000-08:002007-11-08T23:31:57.648-08:00Copying Data from one DataTable to AnotherYou can use <span class="ArticleMainHeading"><span id="ctl00_ContentPlaceHolder1_ArticleHeader1_LabelHeading" style="width: 100%;">ImportRow method to do this by calling NewRow adds a row to the table using the existing table schema, but with default values for the row, and sets the DataRowState to Added. Calling ImportRow preserves the existing DataRowState along with other values in the row. If the DataRow that is passed as a parameter is in a detached state, it is ignored, and no exception is thrown.<br /><br /><span style="font-weight: bold;">Sample Code</span><br /><br /><span style="color: rgb(0, 0, 153);">For Each dr As DataRow In sourceTable.Rows</span><br /><br /><span style="color: rgb(0, 0, 153);"> destinationTable.ImportRow(dr)</span><br /><br /><span style="color: rgb(0, 0, 153);">Next</span><br /><br />But if the destination table have the same structure you can use this clone method copies the structure of the DataSet that including all datatable schemas, relations, and constraints.<br /><br /><span style="font-weight: bold;">Sample Code</span><br /><br /><span style="color: rgb(0, 0, 153);">Dim dsDestination As DataSet </span><br /><span style="color: rgb(0, 0, 153);">' clone method copies the structure of the DataSet, </span><br /><span style="color: rgb(0, 0, 153);">' including all datatable schemas, relations, and constraints </span><br /><span style="color: rgb(0, 0, 153);">dsDestination = ds.Clone()</span><br /><br /><span style="color: rgb(0, 0, 153);">For Each dr As DataRow In ds.Tables(0).Rows</span><br /><span style="color: rgb(0, 0, 153);"> dsDestination.Tables(0).ImportRow(dr)</span><br /><span style="color: rgb(0, 0, 153);">Next<br /><br /><a href="http://vbnetsample.blogspot.com"><span style="color: rgb(0, 0, 0);">vb.net sample code</span></a><br /></span></span> </span>Unknownnoreply@blogger.com5tag:blogger.com,1999:blog-6215844475637970091.post-22543690227725449792007-11-06T09:05:00.000-08:002007-11-06T09:05:54.568-08:00Developers slam Microsoft's Visual Basic planMore than 100 influential developers using Microsoft products have signed a petition demanding the software company reconsider plans to end support for Visual Basic in its "classic" form.<br /><br />The developers, members of Microsoft's Most Valuable Professional program which recognizes influential members of the developer community, claim the move could kill development on millions of Visual Basic 6 (VB6) applications and "strand" programmers that have not been trained in newer languages.<br /><br />Microsoft said it will end standard support for Visual Basic 6 at the end of this month, ending free incident support and critical updates. Both services will be available for a fee for another three years.<br /><br />But MVPs hope Microsoft will reconsider not just VB6's support options, but will continue to develop the language alongside its newer Visual Basic.Net.<br /><br />"By providing a new version of a COM-based Visual Basic within the Visual Studio IDE, Microsoft will help maintain the value of its clients' existing code, demonstrate its ongoing commitment to the core Visual Basic language, and greatly simplify the adoption of VB.NET by those that wish to do so," the petition says. "The decisions of if, how, and when to migrate code to .NET should lie with the customer."<br /><br />The problem, say the dissenting developers, is that when Microsoft made Visual Basic.Net (or Visual Basic 7) the successor to VB6, it actually killed one language and replaced it with a fundamentally different one. It's effectively impossible to migrate VB6 applications to VB.Net, and for VB6 developers, learning VB.Net is as complex as learning a completely new programming language, critics say.<br /><br />"The .Net version of Visual Basic is Visual Basic in name only," wrote developer and author Rich Levin in a recent blog entry. "Any organization with an investment in Visual Basic code--consultants, ISVs, IT departments, businesses, schools, governments--are forced to freeze development of their existing VB code base, or reinvest virtually all the time, effort, intellectual property, and expense to rewrite their applications from scratch."<br /><br />Microsoft continues to develop C++ alongside C#, the language's .Net counterpart, and the company should do the same with "classic" Visual Basic and VB.Net, the petition argues. Microsoft introduced VB.Net in 2000, and since then, developer use of VB6 and older versions has declined steadily. Many of those leaving the language behind are migrating not to VB.Net but to non-Microsoft languages such as Java, according to some surveys. For example, a November 2004 survey of developers in Europe, the Middle East and Africa by Evans Data found that Visual Basic had lost 25 percent of its developer base in those areas since 2003.<br /><br />In North America most Visual Basic developers continued to use VB6 and older versions--45 percent of all North American developers, compared with 34 percent for Visual Basic.Net. Fifty-four percent of North American developers used some sort of Visual Basic.<br /><br />"One of the main issues keeping VB6 and earlier developers from making the migration to VB.Net is the steepness of the learning curve," said Albion Butters, Evans Data's international analyst, in a statement. "The difficulty in moving existing VB6 apps to VB.Net is, in some cases, insurmountable."<br /><br />While the developers' argument may make sense, it is probably a moot point, as Microsoft is unlikely to change its stance on VB6, say some industry observers.<br /><br />"All software--desktop apps, languages, databases, whatever--gets 'end-of-lifed' eventually, some unfortunately, some fortunately," said Jez Higgins, a Birmingham-based developer. "The fundamental programming disciplines aren't tied to any one language or any one way or working. They won't disappear out the side of your head. I suggest these blokes buck up and get on."<br /><br />"The future of programming is clear, and object-oriented languages designed from the get-go for Web and Internet-enabled functionality are the future," wrote one developer in response to Levin's post. "No amount of romanticizing VB6 is going to change that."<br /><br />www.news.comUnknownnoreply@blogger.com2tag:blogger.com,1999:blog-6215844475637970091.post-3807874159068033852007-11-02T09:09:00.002-07:002007-11-02T09:09:43.688-07:00DataSetA data set (or dataset) is a collection of data, usually presented in tabular form. Each column represents a particular variable. Each row corresponds to a given member of the data set in question. It lists values for each of the variables, such as height and weight of an object or values of random numbers. The data set may comprise data for one or more members, corresponding to the number of rows.<br /><br />Historically, the term originated in the mainframe field, where it had a well-defined meaning, very close to contemporary computer file. This topic is not covered here.<br /><br />In the simplest case, there is only one variable, and then the data set consists of a single column of values, often represented as a list.<br /><br />The values may be numbers, such as real numbers or integers, for example representing a person's height in centimeters, but may also be nominal data (i.e., not consisting of numerical values), for example representing a person's ethnicity. For each variable, the values will normally all be of the same kind. However, there may also be "missing values", which need to be indicated in some way.<br /><br />In statistics data sets usually come from actual observations obtained by sampling a statistical population, and each row corresponds to the observations on one element of that population. Data sets may further be generated by algorithms for the purpose of testing certain kinds of software.<br /><br />While the term suggests a relationship to set theory it should not be assumed that a given data set is, in fact, a set in the usual mathematically sense. The rows of a data set need not be distinct, and so a data set is technically a multiset.<br /><br />From Wikipedia, the free encyclopediaUnknownnoreply@blogger.com0tag:blogger.com,1999:blog-6215844475637970091.post-11210343463792335642007-10-30T03:52:00.000-07:002007-10-30T03:52:17.166-07:00SQL Helper ClassMicrosoft .net framework consists of ADO .NET which enables the developer to interact with the database. ADO .NET provides many rich features that can be used to retrieve and display data in a number of ways. Apart from the flexibility provided by the ADO .NET, sometimes we find ourselves repeating the same code again and again. Consider that at some point in our application we need to pass some parameters and retrieve some information from the database. We can perform this task by writing 5-6 lines of code which is cool. But when later we need to pass the parameters we have to write those 5-6 lines again which is not cool.<br /><br /><span style="font-weight: bold;">Methods</span><br /><ul><li><span style="color: rgb(0, 0, 153);">ExecuteDataset </span>Retrieve multiple rows from the database and return value to DataSet class.</li></ul><ul><li><span style="color: rgb(0, 0, 153);">ExecuteNonQuery </span>Executes a Transact-SQL statement against the connection and returns the number of rows affected<br /></li></ul><ul><li><span style="color: rgb(0, 0, 153);">ExecuteNonQueryReturn </span>No return value.<br /></li></ul><ul><li><span style="color: rgb(0, 0, 153);">ExecuteReader </span>Retrieve multiple rows from the database and return value to SqlDataReader class.<br /></li></ul><ul><li><span style="color: rgb(0, 0, 153);">ExecuteScalar </span>Retrieve a single row instead of group of rows and return value to object.<br /></li></ul><ul><li><span style="color: rgb(0, 0, 153);">ExecuteXmlReader </span>Sends the CommandText to the Connection and builds an XmlReader object.</li></ul><br /><span style="font-weight: bold;">Summary</span><br /><ul><li>It is used for Database Access other than System.Data.SqlClient or System.Data.Oledb</li></ul><ul><li>SqlHelper() - This method used to reduce the lines of connecting the database than when we are using the SqlDataAdapter or OleDbAdapter. </li></ul><ul><li>You can download sql helper dll at <a href="http://msdn.microsoft.com/msdnmag/code/Default.aspx?level=root%2cVB%2cBin&url=http%3a%2f%2fmsdn.microsoft.com%2fmsdnmag%2fissues%2f05%2f11%2fMembership%2fDefault.aspx">this</a><br /></li></ul><br /><span style="font-weight: bold;">Sample Code<br /><br /></span><span style="color: rgb(0, 0, 153);">' Very short command</span><br /><span style="color: rgb(0, 0, 153);">Dim nResult as integer</span><br /><span style="color: rgb(0, 0, 153);">nResult = Convert.ToInt32(SqlHelper.ExecuteScalar(ConnectionString, CommandType.Text, "Select Count(id) from table"))</span><br /><span style="font-weight: bold;"><br /></span>Unknownnoreply@blogger.com4tag:blogger.com,1999:blog-6215844475637970091.post-2681100112283264322007-10-29T04:10:00.000-07:002007-10-29T04:10:07.375-07:00Using SqlParameter ClassRepresents a parameter to a SqlCommand and optionally its mapping to DataSet columns. This class cannot be inherited.<br /><br />You should use parameters to filter queries in a secure manner. But I recommend to use parameters when you try to pass the datetime value in your query.<br /><br />The process of using parameter contains two steps: <br /><ul><li>create SqlParameter object and insert there value with applicable properties</li><li>define the parameter in the SqlCommand command string, and assign the SqlParameter object to the SqlCommand object. When the SqlCommand executes, parameters will be replaced with values specified by the SqlParameter object.</li></ul><br /><span style="font-weight: bold;">Sample Code</span><br /><br />Imports Namespace: System.Data.SqlClient<br /><br /> <span style="color: rgb(51, 51, 255);"> ' Insert string</span><br /><span style="color: rgb(51, 51, 255);"> Dim sql As String = " INSERT INTO tblZipCode([ZIPCODE], [STATE], [CITY], [TestDate])</span><span style="color: rgb(51, 51, 255);"> VALUES(@ZIPCODE, @STATE, @CITY), @TestDate"</span><br /><br /><span style="color: rgb(51, 51, 255);"> ' Create sql parameter</span><br /><span style="color: rgb(51, 51, 255);"> Dim param(3) As SqlParameter</span><br /><br /><span style="color: rgb(51, 51, 255);"> param(0) = New SqlParameter("@ZIPCODE", SqlDbType.VarChar)</span><br /><span style="color: rgb(51, 51, 255);"> param(0).Value = "60000"</span><br /><br /><span style="color: rgb(51, 51, 255);"> param(1) = New SqlParameter("@STATE", SqlDbType.VarChar)</span><br /><span style="color: rgb(51, 51, 255);"> param(1).Value = "Statename"</span><br /><br /><span style="color: rgb(51, 51, 255);"> param(2) = New SqlParameter("@CITY", SqlDbType.VarChar)</span><br /><span style="color: rgb(51, 51, 255);"> param(2).Value = "Cityname"</span><br /><br /><span style="color: rgb(51, 51, 255);"> ' Recommend to use sql param when you try to send datetime value</span><br /><span style="color: rgb(51, 51, 255);"> param(3) = New SqlParameter("@TestDate", SqlDbType.DateTime)</span><br /><span style="color: rgb(51, 51, 255);"> param(3).Value = DateTime.Now</span><br /><br /><span style="color: rgb(51, 51, 255);"> ' Create Connection string</span><br /><span style="color: rgb(51, 51, 255);"> Dim sConnection As New SqlConnection("server=(local);uid=sa;pwd=pass;database=db")</span><br /><span style="color: rgb(51, 51, 255);"> sConnection.Open()</span><br /><br /><span style="color: rgb(51, 51, 255);"> ' Create Sql Command</span><br /><span style="color: rgb(51, 51, 255);"> Dim command As SqlCommand = sConnection.CreateCommand()</span><br /><span style="color: rgb(51, 51, 255);"> command.CommandText = sql</span><br /><br /><span style="color: rgb(51, 51, 255);"> ' Add Parameter to command</span><br /><span style="color: rgb(51, 51, 255);"> command.Parameters.AddRange(param)</span><br /><br /><span style="color: rgb(51, 51, 255);"> ' Execute command</span><br /><span style="color: rgb(51, 51, 255);"> Dim nResult As Integer = command.ExecuteNonQuery()</span><br /><br /><span style="color: rgb(51, 51, 255);"> If nResult > 0 Then</span><br /><span style="color: rgb(51, 51, 255);"> Console.WriteLine("Insert completed")</span><br /><span style="color: rgb(51, 51, 255);"> End If</span><br /><br /><span style="color: rgb(51, 51, 255);"> sConnection.Close()</span><br /><span style="color: rgb(51, 51, 255);"> command.Dispose()</span>Unknownnoreply@blogger.com36tag:blogger.com,1999:blog-6215844475637970091.post-47027277395367796422007-10-27T11:18:00.000-07:002007-10-27T11:18:58.356-07:00SqlCommand Methods<span style="font-weight: bold;">ExecuteNonQuery</span> <br /><div style="text-align: left;"><ul><li>Overridden. Executes a Transact-SQL statement against the connection and returns the number of rows affected.</li></ul><span style="font-weight: bold;">ExecuteReader</span> <br /><ul><li>Overloaded. Sends the CommandText to the Connection and builds a SqlDataReader.</li></ul><span style="font-weight: bold;">ExecuteScalar</span> <br /><ul><li>Overridden. Executes the query, and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored.</li></ul><span style="font-weight: bold;">ExecuteXmlReader</span> <br /><ul><li>Sends the CommandText to the Connection and builds an XmlReader object.</li></ul></div>Unknownnoreply@blogger.com1